Node.js Sailsjs更新模型json
假设有一个这样定义的用户模型Node.js Sailsjs更新模型json,node.js,sails.js,Node.js,Sails.js,假设有一个这样定义的用户模型 ... attributes: { properties: { type: 'json', required: true, defaultsTo: { canEdit: { owned: false, other: false } } } } 如何更新user.propert
...
attributes: {
properties: {
type: 'json',
required: true,
defaultsTo: {
canEdit: {
owned: false,
other: false
}
}
}
}
如何更新
user.properties.canEdit.owned
和user.properties.canEdit.other
?可以这样做
User
.findOne()
.where({ ... })
.then(function(user) {
user.properties.canEdit.owned = true;
user.properties.canEdit.other = false;
user.save(function(err) { ... });
});
可以这样做
User
.findOne()
.where({ ... })
.then(function(user) {
user.properties.canEdit.owned = true;
user.properties.canEdit.other = false;
user.save(function(err) { ... });
});
继续,将您的解决方案转移到一个新的答案,并自己接受它!继续,将您的解决方案转移到一个新的答案,并自己接受它!