Search code examples
mongodbmeteor

unset a property from a mongodb document


This Meteor server side code tries to remove the property abc from a document in the users collection but it does not remove it when I check on the mongodb console.

What am I doing wrong? Thanks

Meteor.users.update({_id: userId}, {$unset: {abc: ""}});

Solution

  • I think that what you want to do is:

    Meteor.users.update({_id: userId}, {$unset: {abc: 1}});
    

    I agree that the syntax is confusing: 1 actually stands for true