'RoboMongo - Cannot Remove Documents from Collection
I'm using RoboMongo to delete a number of documents that match a query. However, it is saying no documents have been delete with the following:
db.getCollection('assets').remove( { "source": "red" } );
However, this works perfectly:
db.getCollection('assets').find( { "source": "red" } );
and displays all the records with the source "red".
Is there any reason why the records are not being removed and robomongo is just outputting 0?
Kind Regards,
Solution 1:[1]
Are you running with a replica set? If so make sure that you are running the remove command on the primary node.
Solution 2:[2]
DeleteMany worked for me: https://docs.mongodb.com/v3.2/reference/method/db.collection.deleteMany/#db.collection.deleteMany
db.getCollection('assets').deleteMany({source: 'red'})
This should return
/* 1 */
{
"acknowledged" : true,
"deletedCount" : number // which is the number of documents deleted
}
From the above query, I removed all passengers that the snapshot id is 5c749daee3a0ec00047ffd5c
Solution 3:[3]
You can try this one:
db.assets.remove( {source : "red" } )
Solution 4:[4]
You can try this query:
db.assets.remove( { "source":"red"} )
Solution 5:[5]
Try removing the double quotes around the field name and try something like this:
db.getCollection('assets').remove( { source: "red" } );
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Gabriel |
| Solution 2 | Theophilus Omoregbee |
| Solution 3 | deChristo |
| Solution 4 | Mital Gajjar |
| Solution 5 | Aqib Javed |

