我按照文档中js的调用方法进行了数据库的更新操作,但发现数据库又多出了一行新的数据,原来的数据没有被更新。请问更新单列数据怎么做?
比如说下面这个表,我想更新score这个分数
objectId cheatMode playerName score createAt UpdateAt
53323dc9e4b049888e91e9bb true Sean Plott 1337 13:57:23 13:57:23
但是执行下面的程序后
var GameScore = AV.Object.extend("GameScore");
var gameScore = new GameScore();
gameScore.set("score", 1337);
gameScore.set("playerName", "Sean Plott");
gameScore.set("cheatMode", false);
gameScore.save(null, {
success: function(gameScore) {
// Now let's update it with some new data. In this case, only cheatMode and score
// will get sent to the cloud. playerName hasn't changed.
gameScore.set("score", 1338);
gameScore.save();
}
});
发现变成了
objectId cheatMode playerName score createAt UpdateAt
53323dc9e4b049888e91e9bb true Sean Plott 1337 13:57:23 13:57:23
53326b4fe4b049888e927ffb true Sean Plott 1338 13:59:05 13:59:05
期望结果
objectId cheatMode playerName score createAt UpdateAt
53323dc9e4b049888e91e9bb true Sean Plott 1338 13:57:23 13:59:05
已在群里回复。
更新对象,需要知道对象的objectId,然后去查询这个对象,或者直接设备AV.Object的id属性,save会主动变成更新。