Registry / database / resolve-storage-mysql

resolve-storage-mysql

JSON →
library0.23.2jsnpmunverified

An adapter for the reSolve framework that stores domain events in a MySQL database. Version 0.23.2 is the latest stable release, with a slow release cadence. It provides event persistence for CQRS/Event Sourcing applications, using the mysql2 library under the hood. Compared to other adapters (e.g., Postgres, SQLite), it offers MySQL-specific connection settings and table configuration.

npm install resolve-storage-mysql
INSTALL
IMPORT
SIG · RESOLVE-STORAGE-MY
R
resolve-storage-mysql
databasejavascriptv0.23.2
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-storage-mysql'
import { createAdapter } from 'resolve-storage-mysql'
The module exports a default function. Named import will not work.
default (require)
const createAdapter = require('resolve-storage-mysql')
const { createAdapter } = require('resolve-storage-mysql')
CommonJS require works if the package supports it.

Shows how to import and configure the MySQL adapter with environment variables.

import createAdapter from 'resolve-storage-mysql' const adapter = createAdapter({ host: process.env.MYSQL_HOST ?? 'localhost', port: Number(process.env.MYSQL_PORT ?? 3306), user: process.env.MYSQL_USER ?? 'user', password: process.env.MYSQL_PASSWORD ?? 'password', database: process.env.MYSQL_DATABASE ?? 'events', tableName: 'events' }) await adapter.init() // adapter is ready to be used with resolve-es
Debug
Known issues
gotchaThe `tableName` parameter is required and must be specified in the config object.
fix
Always include 'tableName' in the config object passed to createAdapter.
affects: >=0.0.0
gotchaThe adapter does not create the database automatically; the database must exist before calling createAdapter.
fix
Ensure the MySQL database specified in `database` exists before initializing the adapter.
affects: >=0.0.0
gotchaThe `port` parameter must be a number, not a string.
fix
Use `Number(process.env.MYSQL_PORT) ?? 3306` or hardcode as a number.
affects: >=0.0.0
gotchaThe adapter uses `mysql2` internally; connection settings follow mysql2 documentation.
fix
Refer to mysql2 documentation for additional connection options like `socketPath`, `ssl`, etc.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'resolve-storage-mysql'
Package is not installed or not in node_modules.
fix
Run `npm install resolve-storage-mysql` or `yarn add resolve-storage-mysql`.
TypeError: createAdapter is not a function
Named import used instead of default import.
fix
Use `import createAdapter from 'resolve-storage-mysql'` (default import) instead of `import { createAdapter } from 'resolve-storage-mysql'`.
Upgrade
Version history
0.23.2latest on npm
Audit
Dependencies
mysql2requiredMySQL client library used for database connections
Agent activity
8 hits · last 30 days
node
8
Resources
resolve-storage-mysql — npm install resolve-storage-mysql · libregistry