gpt4 book ai didi

javascript - parse.com 行更新 javascript

转载 作者:行者123 更新时间:2023-12-03 11:07:04 24 4
gpt4 key购买 nike

我有类(class)并且知道行 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);
}
});

但出现错误 “无法创建新对象,错误代码:拥有此项目

最佳答案

当使用new创建point时,它尚未同步。在保存之前获取模型将解决该问题。

使用 promise :

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);

关于javascript - parse.com 行更新 javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27799917/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com