Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (6.1k points)
kindly explain about truncating a collection in MongoDB?

1 Answer

0 votes
by (11.7k points)

Collections in MongoDB can be easily truncated using db.collection.remove() command. It has two syntaxes. The remove method can have a query document and an optional justOne boolean.

db.collection.remove(

   <query>,

   <justOne>

)

Taking query document and an optional remove options document

db.collection.remove(

   <query>,

   {

     justOne: <boolean>,

     writeConcern: <document>,

     collation: <document>

   }

)

Related questions

0 votes
4 answers
asked Feb 25, 2021 in SQL by rahulnayar01123 (6.1k points)
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Sep 6, 2019 in SQL by Sammy (47.6k points)

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...