I have a collection in MongoDB, which is like following:
{
\"_id\" : \"5327010328645530500\",
\"members\" : [
{
\"participationCo
In the meantime the update method is deprecated. Therefore one possible up-to-date solution to this would be using the updateMany method instead.
db.clusters.updateMany({},
{$pull: {members: {tweetID: '5327010328645530500'}}})
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.
This will delete multiple tweets in a single query just pass an array to $in:-
db.clusters.update({},
{$pull: {members: {$in: [ {tweetID: '5327010328645530500'},{"tweetID" : "2820402625046999289"} ] } } },
{multi: true});
The above method doesnt work in mongoose so for mongoose do:-
db.clusters.update({},
{$pull: {members:[ {tweetID: '5327010328645530500'},{"tweetID" : "2820402625046999289"} ] } });