I need to update particular fields of multiple objects stored in a class. I can do this from the client, but I don't like the idea of it handling that extra bandwidth. How can I update and save objects I've iterated over in a Cloud Code query? Essentially, what's the JS equivalent of the following Swift method?
var query = PFQuery(className:"GameScore")
query.whereKey("playerName", equalTo:"Sean Plott")
query.findObjectsInBackgroundWithBlock {
(objects: [AnyObject]?, error: NSError?) -> Void in
if error == nil {
// The find succeeded.
println("Successfully retrieved \(objects!.count) scores.")
// Do something with the found objects
if let objects = objects as? [PFObject] {
for object in objects {
// Update object here
}
// Save your changes to ALL objects
PFObject.saveAllInBackground()
}
} else {
// Log details of the failure
println("Error: \(error!) \(error!.userInfo!)")
}
}