Registry / database / mumba-microservice-sql

mumba-microservice-sql

JSON →
library0.5.11jsnpmunverified

A Mumba Microservice module (v0.5.11) that provides SQL database support via Sequelize. It integrates with the Mumba DI container, expecting a 'config' object with a 'db' property for Sequelize options. Models are added to the 'dbModels' group. Includes migration support via Knex for MySQL. The package ships TypeScript definitions, targets Node >=6, and is specific to the Mumba microservice framework.

npm install mumba-microservice-sql
INSTALL
IMPORT
SIG · MUMBA-MICROSERVICE
M
mumba-microservice-sql
databasejavascriptv0.5.11
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.

SqlDatabase
import { SqlDatabase } from 'mumba-microservice-sql';
import SqlDatabase from 'mumba-microservice-sql';
Named export, not default. Requires a DI container with 'config' registered.
db
const db = container.get('db');
import { db } from 'mumba-microservice-sql';
The db instance is not directly exported; it is registered in the DI container as 'db'.
dbModels
const models = container.get('dbModels');
import { dbModels } from 'mumba-microservice-sql';
Models are retrieved from the container, not imported directly from the package.

Shows instantiation of SqlDatabase with config and registration in a DI container, plus model registration.

import { Container } from 'dicontainer'; import config from './config'; import { SqlDatabase } from 'mumba-microservice-sql'; const container = new Container(); container.object('config', () => config); // Register SQL database module const sqlDb = new SqlDatabase(config); container.instance('db', sqlDb); // Register a model container.factory('fooModel', (c: any) => { const db = c.get('db'); return db.sequelize.define('foo', { name: Sequelize.STRING }); }, ['dbModels']); // Initialize container.init();
Debug
Known issues
breakingRequires Node >=6, older Node versions are unsupported.
fix
Upgrade Node to version 6 or higher.
affects: all
gotchaThe 'db' instance is not directly exported; it must be retrieved from the DI container after the module is registered.
fix
Use container.get('db') instead of importing directly.
affects: all
gotchaMigration changelog table must be uniquely named when using a shared database; otherwise migrations conflict.
fix
Set a unique 'knex' property in the config's db section.
affects: all
Errors
Common errors & fixes
Cannot find module 'mumba-microservice-sql'
Package not installed.
fix
Run npm install mumba-microservice-sql --save
Sequelize is not defined
Missing Sequelize peer dependency.
fix
Install sequelize: npm install sequelize
Property 'knex' does not exist on type 'Config'
TypeScript config type missing knex property for migrations.
fix
Add 'knex?: string' to your Config type definition.
Upgrade
Version history
0.5.11latest on npm
Audit
Dependencies
sequelizerequiredORM used for SQL database operations
dicontaineroptionalDI container integration for model registration
knexoptionalUsed for database migrations
mysqloptionalRequired for MySQL migrations
Agent activity
2 hits · last 30 days
node
2
Resources
mumba-microservice-sql — npm install mumba-microservice-sql · libregistry