@ocoda/event-sourcing-postgres
v4.1.0
Published
NestJS Event Sourcing Library (@postgres)
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 PostgresEventStore and PostgresSnapshotStore: they keep events and snapshots in PostgreSQL, with a global position per pool for readAll(). It is tested on PostgreSQL 14 to 18.
Installation
The pg (^8.15.0) and pg-cursor (^2.14.0) drivers are peer dependencies, so install them next to the core module. TypeScript projects also need their type definitions:
npm install @ocoda/event-sourcing @ocoda/event-sourcing-postgres pg pg-cursor
npm install --save-dev @types/pg @types/pg-cursorRequires 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 table 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 📗
- PostgreSQL: 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
