# How to remove all items from a MongoDB collection

> Learn how to remove all items from a MongoDB collection by calling the deleteMany method and passing it an empty object, with a full Node.js example.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2020-10-29 | Topics: [Database](https://flaviocopes.com/tags/database/) | Canonical: https://flaviocopes.com/mongodb-delete-all-from-collection/

When working with [MongoDB](https://flaviocopes.com/mongodb/) you might have the need to remove all items from a collection.

You can do so by calling the `deleteMany` method of a collection, passing an empty object.

Like this:

```js
yourcollection.deleteMany({})
```

Here's a full example:

```js
const mongo = require('mongodb').MongoClient
const url = 'mongodb://localhost:27017'
let db, jobs

mongo.connect(
  url,
  {
    useNewUrlParser: true,
    useUnifiedTopology: true
  },
  (err, client) => {
    if (err) {
      console.error(err)
      return
    }
    db = client.db('jobs')
    jobs = db.collection('jobs')

    jobs.deleteMany({})
  }
)
```
