I have been trying to run my Parse Cloud Code for some time and can not seem to get around this problem:
I have an array of Parse objectId
's called IDArray. I then am sending the array as a parameter of a PFCloud
call. Once the array has been sent to the Cloud Code, I can not seem to successfully create a for loop
that goes through and updates a number value stored as "points" on Parse for each objectId
.
In a nutshell, this is all I am trying to accomplish:
- I just need to be able to have the
for loop
go through eachobjectId
and perform an action for each ID.
I have been trying to get this to work for some time but have had no luck. Here is the code that I have been trying to manipulate - hopefully it will give someone a starting point to answer my question.
Parse.Cloud.define('updateAllUsers', function(request, response) {
var UserData = Parse.Object.extend('UserData');
var query = new Parse.Query(UserData);
var list = request.params.listID;
var currentuser = request.params.user;
for (var i = 0; i < list.length; i++) {
var userdata = list[i];
query.get(userdata, {
success: function(UserData) {
response.success('Should add up');
UserData.addUnique('Done', +1);
UserData.save();
},
error: function() {
response.error('something went wrong' );
}
});
}
});
If someone could please help me with this I would be very grateful. Thank you