Registry / database / hemera-sql-store

hemera-sql-store

JSON →
library7.0.0jsnpmunverified

Generic SQL client for the Hemera microservices framework using Knex. Version 7.0.0 is the latest stable release. This package provides a store pattern for SQL databases, supporting MySQL, MariaDB, SQLite, and PostgreSQL via Knex. It integrates with Hemera's plugin system and optionally with Hemera-Joi for validation. The package requires a Nats connection for Hemera and a Knex configuration. It wraps Knex to provide CRUD operations within the Hemera pattern. The release cadence is irregular; this version supports Hemera v7.

npm install hemera-sql-store
INSTALL
IMPORT
SIG · HEMERA-SQL-STORE
H
hemera-sql-store
databasejavascriptv7.0.0
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
const hemeraSqlStore = require('hemera-sql-store')
import hemeraSqlStore from 'hemera-sql-store'
The package provides a CommonJS default export. ESM import may not work directly without a bundler or Node.js ESM support.
plugin usage
hemera.use(require('hemera-sql-store'), { knex: { ... } })
hemera.use('hemera-sql-store', { knex: { ... } })
The first argument to hemera.use should be the required module, not a string.
Joi integration
hemera.use(require('hemera-joi'))
hemera.use(require('hemera-sql-store-joi'))
Joi support is provided by the separate 'hemera-joi' package, not bundled here.

Shows how to initialize Hemera with Nats, register the SQL store plugin, and perform a create operation.

const Hemera = require('nats-hemera'); const Nats = require('nats'); const hemera = new Hemera(new Nats(), { logLevel: 'info' }); hemera.use(require('hemera-joi')); hemera.use(require('hemera-sql-store'), { knex: { dialect: 'mysql', connection: { host: '127.0.0.1', user: 'root', password: 'password', database: 'test' } } }); await hemera.ready(); const result = await hemera.act({ topic: 'sql-store', cmd: 'create', table: 'users', data: { name: 'Alice', email: 'alice@example.com' } }); console.log('Inserted:', result);
Debug
Known issues
breakingHemera v7 introduced breaking changes in plugin API.
fix
Ensure you use the correct version of Hemera (v7) and follow the new plugin pattern.
affects: >=7.0.0
deprecatedThe package no longer bundles a SQL driver; you must install one separately.
fix
Install 'mysql', 'pg', or 'sqlite3' as needed.
affects: >=7.0.0
gotchaMissing Nats connection will cause 'ECONNREFUSED' error.
fix
Ensure a Nats server is running and the connection options are correct.
affects: *
gotchaThe 'knex' option must include 'connection' object with correct credentials.
fix
Verify that the host, port, user, password, and database are valid.
affects: *
Errors
Common errors & fixes
Error: Cannot find module 'knex'
'knex' is a peer dependency and must be installed explicitly.
fix
Run 'npm install knex' in your project.
Error: Cannot find module 'mysql'
The MySQL driver is not installed.
fix
Run 'npm install mysql' (or appropriate driver).
Error: Knex: dialect mysql not found
The MySQL driver is missing or incorrectly installed.
fix
Install 'mysql' package and ensure it's in node_modules.
Error: connect ECONNREFUSED 127.0.0.1:3306
No MySQL server is running at the specified address.
fix
Start your MySQL or MariaDB server, or change the connection host/port.
Upgrade
Version history
7.0.0latest on npm
Audit
Dependencies
hemerarequiredCore dependency; requires Hemera and Nats to function.
knexrequiredUsed for SQL query building and execution.
mysqloptionalMySQL driver for Knex; required for MySQL/MariaDB.
Agent activity
11 hits · last 30 days
node
10
Amazon
1
Resources
hemera-sql-store — npm install hemera-sql-store · libregistry