我有这样的Cloud Job代码:
Parse.Cloud.job("createMySpecialObjects", function(request, status) {
var MySpecialObject = Parse.Object.extend("MySpecialObject");
var count = 20 // 20 is greater than 9!
for (var i = 0; i < count; i++) {
var myObject = new MySpecialObject();
myObject.save();
}
status.success("Objects created successfully.");
});
结果我只创建了9个对象。
我认为它每秒连接30个API调用。但也许别人知道的更好?
答案 0 :(得分:4)
下面的代码段显示了如何使用Parse.Object.saveAll
保存多个对象。
Parse.Cloud.job("createMySpecialObjects", function(request, status) {
var MySpecialObject = Parse.Object.extend("MySpecialObject");
var count = 20 // 20 is greater than 9!
var toSaves = [];
for (var i = 0; i < count; i++) {
var myObject = new MySpecialObject();
toSaves.push(myObject);
}
Parse.Object.saveAll(toSaves, {
success: function(saveList) {
status.success("Objects created successfully.");
},
error: function(error) {
status.error("Unable to save objects.")
}
}
});