Database Manual

MongoDB CRUD OperationsMongoDB CRUD操作

CRUD operations create, read, update, and delete documents.CRUD操作创建读取更新删除文档

You can connect with driver methods and perform CRUD operations for deployments hosted in the following environments:您可以连接驱动程序方法,并对以下环境中托管的部署执行CRUD操作:

You can perform CRUD operations in the UI for deployments hosted in MongoDB Atlas.您可以在MongoDB Atlas中托管的部署的UI中执行CRUD操作

Create Operations创建操作

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:MongoDB提供以下方法将文档插入到集合中:

In MongoDB, insert operations target a single collection. 在MongoDB中,插入操作针对单个集合All write operations in MongoDB are atomic on the level of a single document.MongoDB中的所有写入操作都是单个文档级别的原子操作。

The components of a MongoDB insertOne operations.

For examples, see Insert Documents.有关示例,请参阅插入文档

Read Operations读取操作

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:读取操作从集合中检索文档;即查询集合中的文档。MongoDB提供以下方法从集合中读取文档:

You can specify query filters or criteria that identify the documents to return.您可以指定用于标识要返回的文档的查询筛选器或条件

The components of a MongoDB find operation.

For examples, see:例如,请参阅:

Update Operations更新操作

Update operations modify existing documents in a collection. MongoDB provides the following methods to update documents of a collection:更新操作修改集合中的现有文档。MongoDB提供以下方法来更新集合的文档:

In MongoDB, update operations target a single collection. All write operations in MongoDB are atomic on the level of a single document.在MongoDB中,更新操作针对单个集合。MongoDB中的所有写入操作都是单个文档级别的原子操作。

You can specify criteria, or filters, that identify the documents to update. These filters use the same syntax as read operations.您可以指定用于标识要更新的文档的条件或筛选器。这些筛选器使用与读取操作相同的语法。

The components of a MongoDB updateMany operation.

For examples, see Update Documents.有关示例,请参阅更新文档

Delete Operations删除操作

Delete operations remove documents from a collection. MongoDB provides the following methods to delete documents of a collection:删除操作从集合中删除文档。MongoDB提供了以下方法来删除集合中的文档:

In MongoDB, delete operations target a single collection. 在MongoDB中,删除操作针对单个集合All write operations in MongoDB are atomic on the level of a single document.MongoDB中的所有写入操作都是单个文档级别的原子操作。

You can specify criteria, or filters, that identify the documents to remove. These filters use the same syntax as read operations.您可以指定用于标识要删除的文档的条件或筛选器。这些筛选器使用与读取操作相同的语法。

The components of a MongoDB deleteMany operation.

For examples, see Delete Documents.有关示例,请参阅删除文档

Bulk Write批量写入

MongoDB provides the ability to perform write operations in bulk. MongoDB提供了批量执行写操作的能力。For details, see Bulk Write Operations.有关详细信息,请参阅批量写入操作