Hi @lalitha_devi and welcome to the community forums.
You want to use the $unset
operator.
> db.collection.find()
{ "_id" : ObjectId("5edaf777cdb02689803b0b8b"), "name" : "book", "mobile" : "7777777777", "email" : "abc@gmail.com" }
{ "_id" : ObjectId("5edaf78dcdb02689803b0b8c"), "name" : "pen", "mobile" : "8888888888", "email" : "abc@gmail.com" }
> db.collection.updateMany({}, {"$unset": {"email": 1}})
{ "acknowledged" : true, "matchedCount" : 2, "modifiedCount" : 2 }
> db.collection.find()
{ "_id" : ObjectId("5edaf777cdb02689803b0b8b"), "name" : "book", "mobile" : "7777777777" }
{ "_id" : ObjectId("5edaf78dcdb02689803b0b8c"), "name" : "pen", "mobile" : "8888888888" }
>
Note the above will remove the email
field from all documents which is what is sounds like what you want. If you only want to do this on select documents, then you would need to change the {}
portion to contain the proper match for the documents you want to update.