I have a pointer relation between two classes and I need to fetch class A thought class B. It works fine when I use Rest and Android SDK, but I'm constructing a function in CloudCode and it needs to work there.
Tasks (Point to) ExtraTasks
I need to get all ExtraTasks, that a given Task points to.
Any ideas? tks
- Pointer key: taskExtraTasks
- "Parent" Class: Tasks
- "Child" Class: ExtraTasks
Inside the taskExtraTask relation

JSON that constructed the Pointer(Relation?). The relation was constructed via REST api.
{"taskExtraTasks":
{
"__op":"AddRelation",
"objects":
[
{
"__type":"Pointer",
"className":"Tasks",
"objectId":"TASK_ID"
}
]
}
}
CloudCode to get the relation. (Considering the suggestion by JackalopeZero)
Parse.Cloud.define("extras", function(request, response) {
var taskId = "0n5svlATjG";
var taskQuery = new Parse.Query("Tasks");
taskQuery.get(taskId).then(function(task){
var taskRelationQuery = task.relation("taskExtraTasks");
taskRelationQuery.equalTo("taskExtraTasks", task);
return taskRelationQuery.find();
})
.then(function(extraTasks){
// your extra tasks are now accessible here
response.success( extraTasks );
},function(error){
response.error( error );
});
});
Response:
{
"code": 141,
"error": "{\"code\":101,\"message\":\"Object not found.\"}"
}
NOTE: The answer below is correct, although my problem was a bit more complex. I was mistaken Relation and Pointer and couldn't get my head around it, thanks to the lack of information in the REST documentation. If you are stuck in the same way I was, I recommend the creation of Pointer and Relations using Parse UI. After that you can use the REST to deal with those. After you create the Pointer column using the UI, you can add a point via REST using a JSON obj:
// Pointer CLASS_A -> CLASS_B
// Method: "PUT" , path: classes/CLASS_B/CLASS_B_OBJECT_ID
{"pointerName":
{
"__type" :"Pointer",
"className" :"CLASS_A",
"objectId" :"CLASS_A_OBJECT_ID"
}
}
