> For the complete documentation index, see [llms.txt](https://janeto.gitbook.io/mongodb-toan-tap/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://janeto.gitbook.io/mongodb-toan-tap/xoa-document-trong-mongodb/phuong-thuc-remove-trong-mongodb.md).

# Phương thức remove() trong MongoDB

Phương thức remove() trong MongoDB được sử dụng để xóa Document từ Collection. Phương thức remove() nhận hai tham số. Tham số đầu tiên deletion criteria xác định Document để xóa, và tham số thứ hai là justOne.

1. **deletion criteria :** (Tùy ý) Xác định Document để xóa.
2. **justOne :** (Tùy ý) Nếu được thiết lập là true hoặc 1, thì chỉ xóa một Document.

## Cú pháp <a href="#c-ph-p" id="c-ph-p"></a>

Cú pháp cơ bản của phương thức remove() là như sau:

```
>db.COLLECTION_NAME.remove(DELLETION_CRITTERIA)
```

## Ví dụ <a href="#v-d" id="v-d"></a>

Bạn theo dõi Collection có tên mycol có dữ liệu sau:

```
{ "_id" : ObjectId(5983548781331adf45ec5), "title":"MongoDB Overview"}

{ "_id" : ObjectId(5983548781331adf45ec6), "title":"NoSQL Overview"}

{ "_id" : ObjectId(5983548781331adf45ec7), "title":"Tutorials Point Overview"}
```

Ví dụ sau sẽ xóa tất cả Document có title là 'MongoDB Overview':

```
>db.mycol.remove({&#039;title&#039;:&#039;MongoDB Overview&#039;})

>db.mycol.find()

{ "_id" : ObjectId(5983548781331adf45ec6), "title":"NoSQL Overview"}

{ "_id" : ObjectId(5983548781331adf45ec7), "title":"Tutorials Point Overview"}

>
```
