我有课程并且知道行ID,请尝试更新此行,如何在本主题中显示
https://parse.com/questions/updating-a-field-without-retrieving-the-object-first
var Point = Parse.Object.extend("items");
var point = new Point();
point.id = "L8bc5utrVD";
// Set a new value on quantity
point.set("title", "new title");
// Save
point.save(null, {
success: function(point) {
// Saved successfully.
},
error: function(point, error) {
// The save failed.
// error is a Parse.Error with an error code and description.
console.log('Failed to create new object, with error code: ' + error.message);
}
});
但得到错误 “无法创建新对象,错误代码为:有此项”
答案 0 :(得分:1)
使用point
创建new
时,它尚未同步。在保存之前获取模型将解决问题。
使用承诺:
var Point = Parse.Object.extend("items");
var point = new Point();
point.id = "L8bc5utrVD";
point.fetch() // returns a promise
.then(function(){
point.set("title", "new title");
return point.save(); // returns a promise
})
.then(successCallback, failCallback);
答案 1 :(得分:0)
谢谢,但问题在于Parse.Cloud.beforeSave函数