Skip to content

Removing Documents

Removing Documents

To remove one or multiple documents, the commands db.collection.deleteMany() and db.collection.deleteOne() can be used. The latter one can be used to only remove one document.

All the same parameters for finding a document to be removed can be used that were described above in the find section.

For example:

MongoDB
db.users.deleteOne({ username: "test2" })
Example Output
{ acknowledged: true, deletedCount: 1 }