I want to remove a record by id in Mongo console. The following is my collection :
[
{
"_id" : { "$oid" : "4d512b45cc9374271b02ec4f" },
"name" : "Gazza"
},
{
"_id" : { "$oid" : "4d513345cc9374271b02ec6c" },
"name" : "Dave",
"adminOf" : { },
"email" : "[email protected]"
}
]
And the following are the commands that I have implemented but it didn't work :
db.test_users.remove( {"_id":{"$oid":new ObjectId("4d512b45cc9374271b02ec4f")}});
db.test_users.remove( {"_id":{"$oid":"4d513345cc9374271b02ec6c"}});
db.test_users.remove( {"_id":"4d512b45cc9374271b02ec4f"});
db.test_users.remove( {"_id":new ObjectId("4d512b45cc9374271b02ec4f")});