I'm trying to create several objects in a loop in Parse's Javascript SDK.
for (var i = 0; i < results.length; i++){
var user = results[i],
newPuzzle = new Puzzle();
newPuzzle.set("userAsked", user);
newPuzzle.save();
}
But it works only for several objects (from 2 to 5) and then falls to response. I found method Parse.Object.saveAll(list, options) but it doesn't work for creating AFAIK - only for updating.
I also used local function written on pure Node.js with Parse's master key - it can save objects in a loop and works perfectly. But I need working with filesystem and local JavaScript for me is a headache.
How can I create multiple objects in one request in Parse's SDK?
Thanks in advance!
newPuzzle.save()is an asynchronous operation that does not complete instantaneous. You should pass in a success and an error callback function to a) wait until all save operations complete and b) be sure they complete successfully (or what the error is, if they fail). Also see the Parse documentationnewPuzzle.save(null, { success: function() { console.log('SUCCESS', arguments); ), error: function () { console.log('ERROR', arguments); } })neither callback function will be eventually invoked for some save operations? If so, this is a bug and you should file it.