# deleteOne & deleteMany — MongoDB Fundamentals: Documents, Queries and Indexes

Source: https://www.skillbyai.com/en/mongodb/mongo-delete

> Remove documents with deleteOne and deleteMany, and avoid accidentally deleting a whole collection.

## deleteOne()

Removes the first document matching the filter.

```javascript
db.users.deleteOne({ name: "Alan Turing" })
```

Output:

```
{ acknowledged: true, deletedCount: 1 }
```

## deleteMany()

Removes every document matching the filter.

```javascript
db.users.deleteMany({ role: "intern" })
```

Output:

```
{ acknowledged: true, deletedCount: 3 }
```

## Careful with an empty filter

`deleteMany({})` removes **every** document in the collection — always double-check the filter before running it.
