In the MongoDB console how can I remove a record by id? Here\'s my collection :
[
{
\"_id\" : { \"$oid\" : \"4d512b45cc9374271b02ec4f\" },
\"nam
Solution and Example:
1- C:\MongoDB\Server\3.2\bin>mongo (do not issue command yet because you are not connected to any database yet, you are only connected to database server mongodb).
2-
show dbs analytics_database 0.000GB local 0.000GB test_database 0.000GB
3-
use test_database switched to db test_database
4-
db.Collection.remove({"_id": ObjectId("5694a3590f6d451c1500002e")}, 1); WriteResult({ "nRemoved" : 1 })
now you see WriteResult({ "nRemoved" : 1 }) is 1 not 0.
Done.