I am using Parse Javascript SDK.
I have 2 classes with the following details:
"Kid" having properties {name, friends} Here 'friends' is a relation pointing to class Kid's object itself(That is: friend of a kid is another kid)
"Parent" having properties {name, phoneno}
Please assume that following data is in the tables respectively:
"Kid"
ObjId-----------Name ---------- Friends
FiPUuPV1sG ---- Arjun ----------- Kanav(pointer)
2AiPUuPV1s -----Kanav
3BiPUjsdV1 -----Priya
"Parent"
ObjId ----------Name -------- phoneno
vzxAEhHuh9 ----- Chintan -------- 123445
abcAEhHuh0 ----- Chitrang ------- 789766
Now i want to be able to add a relation to the kid "Arjun" named Parent, so that it points to the parent "Chintan"
So, for already inserted data in the classes, I want to create relation among the objects.
I have done this-
var Kid = Parse.Object.extend("Kid");
var Parent = Parse.Object.extend("Parent");
var q1 = new Parse.Query(Kid);
var arjun = q1.get("FiPUuPV1sG");
var q2 = new Parse.Query(Parent);
var chintan = q2.get("vzxAEhHuh9");
var relation = arjun.relation("parent");
relation.add(chintan);
arjun.save();
Please let me know if that is fine!!