Comment on page

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.
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)