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.

database
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.

This package is CommonJS-only; ESM import not supported natively.

const { MySQLService } = require('okanjo-app-mysql');

Both named import patterns work, but destructuring is idiomatic.

const { MariaDBService } = require('okanjo-app-mysql');

CrudService is exported from the package root, not a subpath.

const { CrudService } = require('okanjo-app-mysql');

Destructuring is preferred for consistency.

const { CollectionCrudService } = require('okanjo-app-mysql');

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 footguns
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.
breakingv4.0.0: CrudService: Renamed service.database to service.schema. Removed underscore prefix from crud service functions (e.g., _create => create).
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.
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.
gotchaPeer dependency okanjo-app >=3 required but not installed automatically. If missing, require('okanjo-app-mysql') will fail.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
7 hits · last 30 days
gptbot
3
ahrefsbot
1
Resources