Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (47.6k points)

name: 'book', 

tags: { 

words: ['abc','123'], 

lat: 33, long: 22 

}

Suppose this is a document. How do I remove "words" completely from all the documents in this collection? I want all documents to be without "words":

name: 'book', 

tags: { 

lat: 33, 

long: 22 

}

1 Answer

0 votes
by (106k points)

You can use the below-mentioned code to remove a field completely from a MongoDB document:-

db.example.update({}, {$unset: {words:1}}, false, true);

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
2 answers
asked Sep 13, 2019 in SQL by Sammy (47.6k points)
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...