@ocoda/event-sourcing-mongodb
v4.1.0
Published
NestJS Event Sourcing Library (@mongodb)
Maintainers
Readme
About this library
This is a store integration for @ocoda/event-sourcing, a library for NestJS with the building blocks for Domain-Driven Design (DDD), CQRS and Event Sourcing.
It provides the MongoDBEventStore and MongoDBSnapshotStore: they keep events and snapshots in MongoDB, with a global position per pool for readAll(). It is tested on MongoDB 7, 8 and 9.0, as a standalone server and as a replica set (run a replica set: a single-node one is enough).
Installation
The mongodb driver (^6.10.0 || ^7.0.0; 7.3 or later for MongoDB 8.3 and 9.0) is a peer dependency, so install it next to the core module:
npm install @ocoda/event-sourcing @ocoda/event-sourcing-mongodb mongodbRequires Node.js 22.12 or later and NestJS 12. The package is ESM-only; CommonJS applications load it through require(), which Node.js supports for ES modules since 22.12. Keep it on the same version as @ocoda/event-sourcing.
Upgrading from 3.x
4.0 stores events and snapshots in a new schema (schema v2), and refuses a 3.x event collection until it is migrated. Migrate it once, offline, with migrate(), after a dry run: see the runbook and Migrating from 3.x to 4.0.
Documentation 📗
- MongoDB: the configuration, the schema, the privileges and the migration from 3.x.
- The documentation starts with the installation. The 3.x documentation is at ocoda.github.io/event-sourcing/v3.
- Versioning and support and the changelog.
Contact
Acknowledgments
This library is inspired by @nestjs/cqrs
