Saving Objects In Query With Parse.com Limited To First Rows?
My problem is suppossed to be very common. I have a bunch of users and want to update their ranking position according to their scoring. So I've created a CloudCode function that I
Solution 1:
There are a couple of possible reasons:
- The save() operation is async, but you are effectively finishing the function prematurely with response.success.
- If there are a lot of saves, you could be hitting a burst limit
Either way, putting all the objects to be saved in an array, then call Parse.Object.saveAll, should take care of it:
var toBeSaved = [];
for(var i = 0; i < results.length; ++i) {
a = results[i];
a.set("position", i + 1);
toBeSaved.push(a);
}
Parse.Object.saveAll(tobeSaved, {
success: function () {
response.success('All players updated');
}, error: function (err) {
// handle error
}
});
Post a Comment for "Saving Objects In Query With Parse.com Limited To First Rows?"