I have a list of mongo \'_id\' which I want to delete. Currently I am doing this
# inactive_users --> list of inactive users for item in inactive_users:
You need to pass the ids in a specific format using ObjectId():
ObjectId()
db.users.remove({_id: {$in: [ObjectId('Item1'), ObjectId('Item2'), ObjectId('Item2')]}});
Remove doesn't accept integer - you have to use ObjectId instance with _id format as a string.
Remove
ObjectId
_id
string