@node-ts/bus-mongodb
A Mongodb based persistence for workflow storage in @node-ts/bus
🔥 View our docs at https://bus.node-ts.com 🔥
🤔 Have a question? Join the Discussion 🤔
Installation
Install all packages and their dependencies
npm install @node-ts/bus-mongodb
Configure a new Mongodb persistence and register it with Bus
:
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)
const run = async () => {
const bus = Bus
.configure()
.withPersistence(mongodbPersistence)
.build()
await bus.initialize()
await bus.start()
}
run.then(() => void)
Configuration Options
The Mongodb persistence has the following configuration:
- connection (required) The mongodb connection string to use. This can be a single server, a replica set, or a mongodb+srv connection.
- schemaName (required) The database name to create workflow collections inside.
Development
Local development can be done with the aid of docker to run the required infrastructure. To do so, run:
docker run --name bus-mongodb -p 27017:27017 -d mongo