> For the complete documentation index, see [llms.txt](https://bus.node-ts.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bus.node-ts.com/guide/persistence/mongodb.md).

# MongoDB

**@node-ts/bus-mongodb** provides a persistence adapter based on Mongo DB that's used when storing workflow state.

### Installation

Install the **@node-ts/bus-mongodb** package

```
npm install @node-ts/bus-mongodb
```

Create a new **MongodbPersistence** instance and provide it to the bus configuration.

```typescript
import { Bus } from '@node-ts/bus-core'
import { MongodbPersistence, MongodbConfiguration } from '@node-ts/bus-mongodb'

const configuration: MongodbConfiguration = {
  connection: 'mongodb://localhost:27017',
  databaseName: 'workflows'
}
const mongodbPersistence = new MongodbPersistence(configuration)

// Configure bus to use mongodb as a persistence
const run = async () => {
  await Bus
    .configure()
    .withPersistence(mongodbPersistence)
    .initialize()
}
run.then(() => void)
```
