I'm using sailsJS 0.9.16 with WaterlineJS integrated to implementing my web app. I use WaterlineJS to manipulate my MongoDB database.
Now that I have a colleciton named User with many documents. What I want to do now is that I want to update values for the following attributes: balance & deposit (which have already existed) and update value for the following attribute: spent (which may not existed before). So this is what I've done:
var userUpdate = {
spent: 0, // this attribute may not existed before
balance: newBalance,
deposit: 0
};
User.update({id: userId}, userUpdate)
.done(function(err, userAAA) {
if(err){
console.log(err);
}
else{ // done updating
}
});
It works fine for balance & deposit attributes (they've already existed) but it just didn't work with the spent attribute (I think may be because it hasn't existed before), when I look up that document (using MongoDB) it didn't have the spent attribute . Any ideas on helping me with this problem?