If your document has ObjectId
you can use $type
For Example if your collection is like
{
"_id" : "foo"
}
{
"_id" : "bar"
}
{
"_id" : ObjectId("546c52074e418d78ff419897")
}
{
"_id" : ObjectId("546c52074e418d78ff419898")
}
Remove Only ObjectId
db.coll.remove({_id:{$type:7}})
if your ObjectId is like
{_id:"ObjectId(zzz)"}
{_id:"ObjectId(xxxssssx)"}
you can do it
db.coll.remove({"_id": {$regex:"^ObjectId"}})
if you want delete only one Document
db.coll.remove({"_id": {$regex:"^ObjectId"}},{justOne:true})
obviously, a specific _id
db.coll.remove({"_id" : "ObjectId(xxxssssx)"})