I am trying to update a user object, that is not the current user via useMasterKey. However, I get the error "invalid function" when running it. "blockedFrom" is an array in the user object that stores the list of users who blocked the concerned user and I am trying to add the usernames via addUniqueObject.
Parse.Cloud.job('addBlockedFrom', function(request, status) {
var query = new Parse.Query(Parse.User);
query.equalTo("username", request.params.otherUser);
query.each(function(record) {
record.addUniqueObject("blockedFrom", request.params.username);
return record.save({useMasterKey:true});
},{useMasterKey:true}).then(function(result) {
console.log("addBlockedFrom completed.");
status.success("addBlockedFrom completed.");
}, function(error) {
console.log("Error in addBlockedFrom: " + error.code + " " + error.message);
status.error("Error in addBlockedFrom: " + error.code + " " + error.message);
});
});