Thursday, 22 August 2013

MongoDB opposite of $addToSet to '$removeFromSet'

MongoDB opposite of $addToSet to '$removeFromSet'

I'm aware of the $addToSet method for MongoDB, but I can't find a remove
equivalent anywhere in the docs.
What's the best way to achieve this? Trying to achieve something like the
following:
obj = {
name: 'object1
tags: ['fus', 'ro', 'dah']
}
db.collection.update({name: 'object1'}, {$removeFromSet: { tags: 'dah'}});

No comments:

Post a Comment