In the MongoDB console how can I remove a record by id? Here\'s my collection :
[ { \"_id\" : { \"$oid\" : \"4d512b45cc9374271b02ec4f\" }, \"nam
Very close. This will work:
db.test_users.deleteOne( {"_id": ObjectId("4d512b45cc9374271b02ec4f")});
i.e. you don't need a new for the ObjectId.
Also, note that in some drivers/tools, remove() is now deprecated and deleteOne or deleteMany should be used instead.
remove()
deleteOne
deleteMany