Here is the parse javascript cloud code I wrote. I want to find all objects in subclass \"Example\" having one like and then reset them as four. I have already established the E
A couple of possible issues..
then
function. See http://blog.parse.com/2013/01/29/whats-so-great-about-javascript-promises/save
Try this below, noticing that the .success
should return a result if you NSLog(@"result %@",result)
from your objective-c. Also, the error should be coming through now as well because of response.error(error)
var Example = Parse.Object.extend("Example");
function exampleFunction() {
var query = new Parse.Query(Example);
query.equalTo('Like',1);
return query.find().then(function(examplesLikedOnce){
var promises = [];
for (var i = 0; i < examplesLikedOnce.length; i++) {
var example = examplesLikedOnce[i];
var promise = example.save({Like:4});
promises.push(promise);
}
return Parse.Promise.when(promises).then(function(){
return examplesLikedOnce.length;
});
});
}
Parse.Cloud.define("nice", function(request, response) {
exampleFunction().then(function(numExamples){
response.success("The number of Example objects with 1 like: "+numExamples);
}, function(error){
response.error(error);
});
});