Registry / database / resolve-eventstore-mysql

resolve-eventstore-mysql

JSON →
library0.26.5jsnpmunverified

An adapter for the reSolve CQRS/ES framework that persists events in MySQL databases. Current stable version 0.26.5, released 2021. Works with reSolve v0.26.x (Node ≥10.9). Differentiators: automates schema initialization for event sourcing tables (events, snapshots, subscribers), supports internal and external MySQL via Knex, integrates seamlessly with reSolve's query-side projections. Requires MySQL 5.7+ and a configured reSolve application. Alternative to postgresql or sqlite adapters.

npm install resolve-eventstore-mysql
INSTALL
IMPORT
SIG · RESOLVE-EVENTSTORE
R
resolve-eventstore-mysql
databasejavascriptv0.26.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
✓ import createAdapter from 'resolve-eventstore-mysql'
✗ const createAdapter = require('resolve-eventstore-mysql')
Package is ESM-only since v0.26; named import 'createAdapter' also works (same default export).
createAdapter
✓ import { createAdapter } from 'resolve-eventstore-mysql'
✗ const { createAdapter } = require('resolve-eventstore-mysql')
Named import is preferred for clarity.
initEvents
✓ import { initEvents } from 'resolve-eventstore-mysql'
Utility function to manually initialize event tables; rarely needed as adapter auto-initializes on first connect.

Connects to MySQL, loads events by aggregate ID and event type, then disconnects.

import createAdapter from 'resolve-eventstore-mysql'; const eventStoreAdapter = createAdapter({ host: process.env.MYSQL_HOST || 'localhost', port: parseInt(process.env.MYSQL_PORT || '3306', 10), user: process.env.MYSQL_USER || 'root', password: process.env.MYSQL_PASSWORD || '', database: process.env.MYSQL_DATABASE || 'resolve_events', poolSize: 10, table: 'events', snapshotsTable: 'snapshots', subscribersTable: 'subscribers', }); await eventStoreAdapter.connect(); const events = await eventStoreAdapter.loadEvents({ type: 'UserCreated', aggregateId: '123' }); console.log(events); await eventStoreAdapter.disconnect();
Debug
Known issues
breakingVersion 0.26+ changed export to ESM-only; CommonJS require() throws error.
fix
Switch to ES module imports or use dynamic import().
affects: >=0.26.0
deprecatedOld config option 'eventsTable' replaced by 'table' in v0.23.
fix
Use 'table' instead of 'eventsTable' in adapter config.
affects: >=0.23.0 <0.23?
gotchaDatabase schema not auto-created if using non-root MySQL user without CREATE privileges.
fix
Grant CREATE, ALTER, INSERT, SELECT on the target database before startup.
affects: >=0.0.0
gotchaConnection pool size defaults to 10; too many concurrent connections may exceed MySQL limits (default 151).
fix
Reduce poolSize or increase MySQL max_connections.
affects: >=0.0.0
deprecatedSnapshot table name option 'snapshotsTable' renamed to 'snapshotsTable' in v0.24 (was 'snapshotsTable'?).
fix
Use 'snapshotsTable' if you need to customize; defaults to 'snapshots'.
affects: >=0.24.0 <0.26?
Errors
Common errors & fixes
Error: Cannot find module 'resolve-eventstore-mysql'
Package not installed or wrong version.
fix
npm install resolve-eventstore-mysql@0.26.5
Error [ERR_REQUIRE_ESM]: require() of ES Module not supported.
Using CommonJS require() with ESM-only package v0.26+.
fix
Use import or dynamic import(): const createAdapter = (await import('resolve-eventstore-mysql')).default;
Error: ER_BAD_DB_ERROR: Unknown database 'resolve_events'
Specified MySQL database does not exist.
fix
CREATE DATABASE resolve_events; or change database config.
Error: ER_TABLE_EXISTS_ERROR: Table 'events' already exists
Adapter tried to create tables but they already exist with different schema.
fix
Drop existing tables or use different table names in config.
Upgrade
Version history
0.26.5latest on npm
Audit
Dependencies
mysql2requiredMySQL client driver used internally for database operations
knexrequiredSQL query builder for schema migrations and cross-database compatibility
Agent activity
7 hits · last 30 days
node
6
Meta
1
Resources
resolve-eventstore-mysql — npm install resolve-eventstore-mysql · libregistry