MongoDB can be used locally or hosted on cloud , in any case MongoDB Compass is a great tool for managing collections.
Compass come with a console, which you can use manipulate docs. Let’s learn how to explore and delete documents in a collection
Delete all documents
we can delete all documents using the following on terminal/ Compass console
use myDB db.users.find() -- list all users docs db.users.deleteMany({}) db.users.find() -- check again
Here myDB is my Database and users is one of collection inside it. You can also use filter to delete many documents, for example delemany({uid:1001})
You may also love to read following tutorials
- How to export multiple components in Reactjs - How to render export multiple components in React
- How to add element to mongoose object array in Nodejs - How to add element to a mongodb object array
- How to interact with input in Reactjs - How to handle state and event of input element in React apps
- How to populate multiple MongoDB objects on the same path in express-node - How to populate multiple objects in MongoDB in the same path
- How to populate selected fields in a mongo document path in expressjs - How to populate object in mongo doc at a specific path with specific fields
- How to populate and display nested mongo objectin express-node route - How to populate object in express-MongoDB app
- How to render mongo object in Reactjs - How to render MongoDB object/ObjectId in React/MERN app
- How to render mongo document in Reactjs - How to render mongo document in react component
- How to filter MongoDB object list in express-node app - How to filter a mongo object list in document in express-node app
- How to fix mongo object Type error in Reactjs - How to fix TypeError/undefined in React - MERN application