Reputation: 138
Regarding to exist DB structure, I have PARENT object (CLASS1) and it has relations with CHILD objects (CLASS2).
Suddenly appears task make changes in PARENT if changed CHILD. I have ID of CHILD and don't know how get PARENT ID using Cloud Code.
We alredy migrated DB to MongoDB, and I can see here collection: _Join:CLASS2:CLASS1 and can query it to get related PARENT ID. But it doesn't work on Parse.com.
How I chould build my query?
Upvotes: 1
Views: 233
Reputation: 970
Assume you have 2 Classes, named Parent and Child. You have a relation(many to many) on Parent, named children.
If you want to get children of specific Parent 'parent'.
var query = parent.relation('children').query();
query.find().then(function(list){
},function(error){
});
If you want to get parents of specific Child 'child'(ParseObject, not id string).
var query = new Parse.Query('Parent');
query.equalTo('children', child);
query.find().then(function(list){
},function(error){
});
Upvotes: 1