Reputation: 5799
I have 4 classes in Parse. I am using JavaScript.
1) Rangoli - Main item objects
2) Categories - List of all categories
3) Users - List of all users
4) ItemCategories - List of categories that each items are assigned
Below is the structure of all classes.
Now I am trying to get the following details in a single query.
1) User - Name, email, avatar
2) Rangoli - filename, createdAt
3) Categories - name
This is the JavaScript code that I tried.
var Rangoli = Parse.Object.extend("Rangoli");
var ItemCategories = Parse.Object.extend("ItemCategories");
var query = new Parse.Query(ItemCategories);
var innerQuery = new Parse.Query(Rangoli);
innerQuery.matchesQuery("category", query);
query.find({
success : function (data) {
console.log(JSON.stringify(data));
},
error : function (e) {
}
});
With the above JavaScript code, I am getting the record of ItemCategories record and not all the columns of all pointer class like Categories, User, Rangoli.
Upvotes: 0
Views: 2762
Reputation: 9911
You can include related objects in the results of a query by using the include method. e.g.
var ItemCategories = Parse.Object.extend("ItemCategories");
var query = new Parse.Query(ItemCategories);
query.include("item");
query.include("category");
You can also use this to get objects nested at multiple levels, e.g., query.include(["category.rangoli"]);
but from your data model screenshot I can't see a way to include the Rangoli data with the relationships you have set up.
Upvotes: 1