Registry / database / okanjo-app-mysql

okanjo-app-mysql

JSON →
library5.0.1jsnpmunverified

Service for interfacing with MySQL or MariaDB databases within the Okanjo App ecosystem. Current stable version is 5.0.1, released with breaking changes including dropping MySQL 5.7 support, port numbers must be numeric, and updated dependencies. Provides MySQLService/MariaDBService for direct SQL queries and CrudService/MariaDBCrudService/CollectionCrudService for ORM-like CRUD operations. Requires okanjo-app >=3 as peer dependency. Regular releases with documented breaking changes.

npm install okanjo-app-mysql
INSTALL
IMPORT
SIG · OKANJO-APP-MYSQL
O
okanjo-app-mysql
databasejavascriptv5.0.1
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.

MySQLService
const { MySQLService } = require('okanjo-app-mysql');
import { MySQLService } from 'okanjo-app-mysql';
This package is CommonJS-only; ESM import not supported natively.
MariaDBService
const { MariaDBService } = require('okanjo-app-mysql');
const MariaDBService = require('okanjo-app-mysql').MariaDBService;
Both named import patterns work, but destructuring is idiomatic.
CrudService
const { CrudService } = require('okanjo-app-mysql');
const CrudService = require('okanjo-app-mysql/CrudService');
CrudService is exported from the package root, not a subpath.
CollectionCrudService
const { CollectionCrudService } = require('okanjo-app-mysql');
const CollectionCrudService = require('okanjo-app-mysql').CollectionCrudService;
Destructuring is preferred for consistency.

Shows how to instantiate MySQLService with configuration and run a simple SQL query with callback.

const { MySQLService } = require('okanjo-app-mysql'); const { App } = require('okanjo-app'); const app = new App({ config: { mysql: { host: process.env.DB_HOST ?? 'localhost', port: parseInt(process.env.DB_PORT ?? '3306'), user: process.env.DB_USER ?? 'root', password: process.env.DB_PASSWORD ?? '', database: process.env.DB_NAME ?? 'test' } } }); const mysqlService = new MySQLService(app); mysqlService.query('SELECT 1 + 1 AS solution', [], (err, response) => { if (err) { console.error(err); return; } console.log('Result:', response.results[0].solution); app.shutdown(); }); app.init();
Debug
Known issues
breakingv5.0.0: MySQL 5.7 not supported using MySQL's driver. Port numbers must be numeric. getAffectedRowsCount renamed to getAffectedItemsCount. MariaDB returns BigInt for count fields. query.getRawStatement is now query.getSQL. column.type is now column.getType() returning string enum. All dependencies updated.
fix
Update code to use new method names and numeric ports. For MySQL 5.7 use MariaDB service or stay on v4.
affects: >=5.0.0
breakingv4.0.0: CrudService: Renamed service.database to service.schema. Removed underscore prefix from crud service functions (e.g., _create => create).
fix
Rename references from service.database to service.schema and remove underscore from private methods.
affects: >=4.0.0
breakingv3.0.0: Switched MySQL driver from mysqljs/mysql to mysql/mysql-connector-nodejs. pool property replaced with client. query signature changed to (sql, args, callback, options). getConnection replaced with getSession. CrudService MAX_VALUE class replaced with string constant.
fix
Update all query calls and use session instead of connection. See migration guide.
affects: >=3.0.0
breakingv2.0.0: MySQLService query callback now returns a single response object with results and fields properties. CrudService methods now return Promises; callback optional. _create, _update signatures changed.
fix
Update callback usage and migrate to Promise async/await if needed.
affects: >=2.0.0
gotchaPeer dependency okanjo-app >=3 required but not installed automatically. If missing, require('okanjo-app-mysql') will fail.
fix
Install peer dependency: npm install okanjo-app
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'okanjo-app'
Missing peer dependency okanjo-app.
fix
npm install okanjo-app
Error: Port must be a number
Port provided as string; v5 requires numeric port.
fix
Ensure port is a number, e.g., parseInt(process.env.DB_PORT ?? '3306')
mysqlService.query is not a function
Service not properly initialized or imported incorrectly.
fix
Check import: const { MySQLService } = require('okanjo-app-mysql'); and instantiate with valid app instance.
TypeError: Cannot read property 'results' of undefined
Query callback expected single argument in v2+ but using old two-argument (err, results) pattern.
fix
Update callback signature to (err, response) and use response.results and response.fields.
Upgrade
Version history
5.0.1latest on npm
Audit
Dependencies
okanjo-apprequiredPeer dependency: core framework required by all modules
mysqlrequiredRuntime dependency for MySQL driver (Oracle connector)
mariadbrequiredRuntime dependency for MariaDB driver
Agent activity
2 hits · last 30 days
node
2
Resources
okanjo-app-mysql — npm install okanjo-app-mysql · libregistry