2013-11-25 62 views
2

假設有一個像這樣定義的用戶模型。Sailsjs更新模型json

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

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

+2

繼續前進,並將您的解決方案移至新答案並自行接受! – Plato

回答

4

可以這樣做。

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