Using MongoDB $pull to delete documents within an Array

That’s exactly what the $pull operator does, so in the shell you could use an update like:

db.clusters.update({}, 
    {$pull: {members: {tweetID: '5327010328645530500'}}}, 
    {multi: true})

Set the multi option so that every document is updated, not just the first one.

Leave a Comment