MongoDB Unset

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

Summary
Review Date
Reviewed Item
How to unset MongoDB?
Author Rating
51star1star1star1star1star

“At TekSlate, we are trying to create high quality tutorials and articles, if you think any information is incorrect or want to add anything to the article, please feel free to get in touch with us at info@tekslate.com, we will update the article in 24 hours.”

0 Responses on MongoDB Unset"

    Leave a Message

    Your email address will not be published. Required fields are marked *

    Support


    Please leave a message and we'll get back to you soon.

    3 + 5