Hướng dẫn mongodb delete by filter
Docs Home → MongoDB Manual On this page
➤ Use the Select your language drop-down menu in the upper-right to set the language of the following examples. Delete operations do not drop indexes, even if deleting all documents from a collection. All write operations in MongoDB are atomic on the level of a single document. For more information on MongoDB and atomicity, see Atomicity and Transactions. With write concerns, you can specify the level of acknowledgement requested from MongoDB for write operations. For details, see Write Concern. Docs Home → MongoDB Manual CRUD operations create, read, update, and delete documents. Create or insert operations add new documents to a collection. If the collection does not currently exist, insert operations will create the collection. MongoDB provides the following methods to insert documents into a collection:
In MongoDB, insert operations target a single collection. All write operations in MongoDB are atomic on the level of a single document. For examples, see Insert Documents. Read operations retrieve documents from a collection; i.e. query a collection for documents. MongoDB provides the following methods to read documents from a collection:
You can specify query filters or criteria that identify the documents to return. For examples, see:
Update operations modify existing documents in a collection. MongoDB provides the following methods to update documents of a collection:
In MongoDB, update operations target a single collection. All write operations in MongoDB are atomic on the level of a single document. You can specify criteria, or filters, that identify the documents to update. These filters use the same syntax as read operations. For examples, see Update Documents. Delete operations remove documents from a collection. MongoDB provides the following methods to delete documents of a collection:
In MongoDB, delete operations target a single collection. All write operations in MongoDB are atomic on the level of a single document. You can specify criteria, or filters, that identify the documents to remove. These filters use the same syntax as read operations. For examples, see Delete Documents. MongoDB provides the ability to perform write operations in bulk. For details, see Bulk Write Operations. Docs Home → Start with Guides In this guide, you will delete data from MongoDB. Time required: 10 minutes
Switch to the database and collection you wish to query. In this case you will be using the The following example illustrates using a query filter to delete documents where their The Here is the complete code followed by sample output. If you have completed this guide, you have deleted data from MongoDB. That completes this introduction to CRUD operations in MongoDB. See the following resources for more in-depth information about the concepts presented here:
|