# 删除方法

MongoDB提供以下删除集合文档的方法：

|                                                                                                                                   |                                                  |
| --------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ |
| [db.collection.deleteOne()](https://docs.mongodb.com/manual/reference/method/db.collection.deleteOne/#db.collection.deleteOne)    | 即使多个文档可能与指定过滤器匹配，也最多删除一个与指定过滤器匹配的文档。 *3.2版中的新功能* |
| [db.collection.deleteMany()](https://docs.mongodb.com/manual/reference/method/db.collection.deleteMany/#db.collection.deleteMany) | 删除所有与指定过滤器匹配的文档。 *3.2版中的新功能*                     |
| [db.collection.remove()](https://docs.mongodb.com/manual/reference/method/db.collection.remove/#db.collection.remove)             | 删除单个文档或与指定过滤器匹配的所有文档。                            |

## 附加方法

以下方法也可以从集合中删除文档:

* [`db.collection.findOneAndDelete()`](https://docs.mongodb.com/manual/reference/method/db.collection.findOneAndDelete/#db.collection.findOneAndDelete). [`findOneAndDelete()`](https://docs.mongodb.com/manual/reference/method/db.collection.findAndModify/#findandmodify-wrapper-sorted-remove)提供排序选项。该选项允许删除按指定 order 排序的第一个文档。
* [`db.collection.findAndModify()`](https://docs.mongodb.com/master/reference/method/db.collection.findAndModify/#db.collection.findAndModify).

  [`db.collection.findAndModify()`](https://docs.mongodb.com/master/reference/method/db.collection.findAndModify/#db.collection.findAndModify) 提供了一个排序选项。 该选项允许删除按指定顺序排序的第一个文档.
* [`db.collection.bulkWrite()`](https://docs.mongodb.com/master/reference/method/db.collection.bulkWrite/#db.collection.bulkWrite).

有关更多方法和示例，请参见各个方法的参考页。

译者：杨帅

校对：杨帅


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mongoing.com/mongodb-crud-operations/delete-documents/delete-methods.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
