mobileNavlogo
headerlogo

Blog

MongoDB Unset

12 October, 2020

Related Blogs

Unset a field from Documents

Sample of document, and you want to unset the field “affLink”.

domain.json
{ "_id" : 1,
"domain" : "mkyong.com",
"affLink" : "abc" }
Interested in mastering Mongo DB Training?
Enroll now for FREE demo on Mongo DB Training.

 

To unset a field from all documents, set {multi: true}, else only the field of the first matched document will be removed.

db.domain.update({},{$unset: {affLink:1}},{multi: true});

Output

domain.json
{ "_id" : 1, "domain" : "mkyong.com" }

For indepth understanding click on

 
About Author
Authorlogo
Name

TekSlate

Author Bio

TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills .