Javascript 使用解析云代码更新数据库
我有一份解析云的工作Javascript 使用解析云代码更新数据库,javascript,backbone.js,parse-platform,Javascript,Backbone.js,Parse Platform,我有一份解析云的工作 Parse.Cloud.job("AuthorSearchField", function(request, response) { //get all author var testItemsQuery = new Parse.Query("Author"); //for each item testItemsQuery.each(function (testItem) { //set search field t
Parse.Cloud.job("AuthorSearchField", function(request, response) {
//get all author
var testItemsQuery = new Parse.Query("Author");
//for each item
testItemsQuery.each(function (testItem) {
//set search field
testItem.set("searchField",testItem.get("name").toLowerCase());
testItem.save()
}).then(function() {
response.success("Set searchField");
}, function(error) {
response.error("Uh oh, something went wrong.");
});
});
此作业用于用“名称”内容填充“搜索字段”
我执行这项工作,一切都很好:
但是,基本数据库中没有更新任何内容
我的代码出了什么问题?我可能会迟到,但现在我们开始: 在每个函数内的代码中,您不返回承诺,因此服务器只运行整个过程。 尝试:
返回testItem.save()代码>
我还建议不要一个一个地保存所有这些项目,而是创建批并保存它们,比如说一次保存100个