Query with infos from a pointer

I have a Parse Object that contains a pointer to the user owning this object and i’m trying to do a query of this object with an information from the pointer.

For example, if i’m trying to find all the objects where the name of the user is “John”. Usually i would only do something like myQuery.equalTo(‘name’, ‘John’) but since the name is inside the ‘user’ pointer, how do i do that?

// From JS Doc: should do the work

const userQuery = new Parse.Query('User');
userQuery.equalTo('name', 'John');

const exampleQuery = new Parse.Query('ExampleClass');
exampleQuery.matchesQuery('user', userQuery);
const results = await exampleQuery.find()
// results contains ExampleClass with pointers of field user matching userQuery

Exactly what i needed! Thanks!