I'm trying to save a collection of objects from a Cloud Code function.
After 30-40 objects I get a time out error. My code looks like this:
Parse.Cloud.define("saveInBackground", function (request, response) {
console.log("saveInBackground begin");
var objectsToSave = [];
for (var i = request.params.collectionToSave.length - 1; i >= 0; i--) {
objectsToSave.push(new LikedObject(request.params.collectionToSave[i]));
};
Parse.Object.saveAll(objectsToSave, {
success: function(list) {
// All the objects were saved.
if (response) {
response.success(list);
};
console.log("saveInBackground success");
},
error: function(model, error) {
// An error occurred while saving one of the objects.
if (response) {
response.error(error);
};
console.log("saveInBackground error: " + error.message);
}
});
console.log("saveInBackground end");
});
Can I do something else in order to save a bunch of objects?