Sailsjs更新模型json



假设有一个这样定义的用户模型。

...
attributes: {
    properties: {
        type: 'json',
        required: true,
        defaultsTo: {
            canEdit: {
                owned: false,
                other: false
            }
        }
    }
}

如何更新user.properties.canEdit.owneduser.properties.canEdit.other

可以这样做。

User
.findOne()
.where({ ... })
.then(function(user) {
    user.properties.canEdit.owned = true;
    user.properties.canEdit.other = false;
    user.save(function(err) { ... });
});

最新更新