I am having some trouble making a Parse Cloud function work. I hope someone can bring me some help. I started by following some other function I had written before. But it has been a while; and it seems like things have changed. The text of the function (below) is self explanatory of what I want to do, but the syntax must be wrong because it is not working and I get various errors or deprecation warnings. Here is the code:
Parse.Cloud.define
("removeRecord", function(request, response) {
var objectQuery;
objectQuery = new Parse.Query("Record_List");
objectQuery.equalTo("objectId", request.params.unitID);
objectQuery.equalTo("ownerID", request.params.userID);
objectQuery.find().then
(function(resUnit) {
// If nothing has been found we return an error.
if (!resUnit.length) response.error("NOT-FOUND");
else {
// We set the status field to "DELETED" on the record found.
resUnit.set("status", "DELETED");
response.success();
}
});
});