I have an object class in Parse called Message that has a relation installations to many PFInstallation objects. I use this relation to keep track of which installations currently have local copies of each Message object.
I would like to check each time a Message object is saved whether there are a non-zero number of PFInstallations in each Message's installations relation, and to do so I am using the following method in Cloud Code:
Parse.Cloud.afterSave("Message", function(request) {
var message = request.object;
var query = message.relation("installations").query();
query.count({
success: function(count) {
console.log("count = "+count);
},
error: function(error) {
console.error("Could not count installations for Message": "+error);
}
});
});
However I am getting the following error message:
v8 after_save triggered for Message for user <redacted>:
Input: {"object":{"createdAt":"2015-08-10T18:41:21.041Z","installations":{"__type":"Relation","className":"_Installation"},"isRead":0,"objectId":"N88D2m1bqB","recipient":"[email protected]","sendDate":{"__type":"Date","iso":"2015-08-10T18:40:15.047Z"},"sender":"[email protected]","text":"v8","updatedAt":"2015-08-10T18:41:21.041Z"}}
Result: Success
I2015-08-10T18:41:22.305Z]Could not count installations for Message: [object Object]
I have no idea why I am getting this error message or what the error [object Object] means. In other regular Cloud Code methods I have been able to count the number of objects in a relation just fine using a query like in the example above.
Please let me know what other information or clarifications I can provide to help answer this question.