我正在尝试使用JS-SDK更新用户对象,但我收到了模式错误的重复键。使用StackMob JS-SDK更新用户对象的正确方法是什么?以下是我的代码
var Usr = StackMob.Model.extend({schemaName: 'user'});
var rid = window.localStorage.getItem("devicetoken");
var usr = new Usr({ username: rid });
usr.set({sendnotification: true });
usr.save({
success: function(model, result, options) { console.log('saved'); },
error: function(model, result, options) {console.debug('failed:'+result.error);}
});
答案 0 :(得分:0)
想出答案,您需要直接使用User对象。无需扩展模型
var user = new StackMob.User({ username: rid, sendnotification: true});
user.save({
success: function(model, result, options) { console.log('saved'); },
error: function(model, result, options) {console.debug('failed:'+result.error);}
});