Reputation: 1569
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
Upvotes: 0
Views: 331
Reputation: 4016
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.
}
});
Upvotes: 1