0

im trying to make a query like the one blow, but since i can't test it, i would like to know your opinion about if it would work:

"PencilCase" is a table that contains different pencils: "objectId" - "name" - "createdAt" - ....

"Students" is a table that contains students and specifically a column of a relation of "PencilCase" objects in it.

So if i query for students i wouldn't get the pencilCase objects by default because its a relation, i would have to query for it after.

Now that i have explained it, i want to query for "Students" but i want to limit it by its "PencilCase", so i want to know if the query below would get the job done:

var Class = Parse.Object.extend("PencilCase");
var innerQuery = new Parse.Query(Class);
innerQuery.containsAll("objectId", arrayOfDesiredPensilCases);

var Class = Parse.Object.extend("Students");
var query = new Parse.Query(Class);
query.matchesQuery("pencils", innerQuery);
query.find({
success: function(students) {
        //
    }
});

Thanks, Newton

1 Answer 1

1

Parse provided a very similar scenario that I think it will work for you as well:

var Post = Parse.Object.extend("Post");
var Comment = Parse.Object.extend("Comment");
var innerQuery = new Parse.Query(Post);
innerQuery.exists("image");
var query = new Parse.Query(Comment);
query.matchesQuery("post", innerQuery);
query.find({
  success: function(comments) {
    // comments now contains the comments for posts with images.
  }
});
Sign up to request clarification or add additional context in comments.

1 Comment

I know, I have read the docs and have see this.. but the difference is that my example has the innerQuery in a field of type relation.. thats where my concern is.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.