Docs Home / mongosh

Perform CRUD Operations执行CRUD操作

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

Create Operations创建操作

Create or insert operations add new documents to a collection. If the collection does not exist, create operations also create the collection.创建或插入操作将新文档添加到集合中。如果集合不存在,则创建操作也会创建集合。

You can insert a single document or multiple documents in a single operation.您可以在一次操作中插入单个文档或多个文档。

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

Read Operations读取操作

Read operations retrieve documents from a collection; i.e. query a collection for documents.读取操作从集合中检索文档;即查询集合中的文档。

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

For examples, see Query Documents.有关示例,请参阅查询文档

Update Operations更新操作

Update operations modify existing documents in a collection. You can update a single document or multiple documents in a single operation.更新操作修改集合中的现有文档。您可以在一次操作中更新单个文档或多个文档。

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删除操作

Delete operations remove existing documents from a collection. You can remove a single document or multiple documents in a single operation.删除操作从集合中删除现有文档。您可以在一次操作中删除单个文档或多个文档。

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.有关示例,请参阅删除文档