Registry / database / nukak-mysql

nukak-mysql

JSON →
library1.9.1jsnpmunverified

MySQL adapter for nukak ORM, a TypeScript ORM with declarative JSON query syntax and smart type-safety. Current stable version is 1.9.1. nukak provides a MongoDB-inspired query syntax that compiles to SQL, with full TypeScript inference across joins and nested relations. Unlike traditional ORMs (TypeORM, Sequelize) that use class-based decorators or query builders, nukak serializes queries as JSON, making them transportable from frontend to backend. Supports MySQL, MariaDB, PostgreSQL, SQLite with a unified API. Release cadence is monthly. Requires nukak core ^1.8.1 and mysql2 ^2.3.3 as peer dependencies. Pure ESM package with TypeScript types.

npm install nukak-mysql
INSTALL
IMPORT
SIG · NUKAK-MYSQL
N
nukak-mysql
databasejavascriptv1.9.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.

MySqlAdapter
import { MySqlAdapter } from 'nukak-mysql'
const MySqlAdapter = require('nukak-mysql')
Package is ESM-only; CommonJS require() is not supported.
MySqlQuerier
import { MySqlQuerier } from 'nukak-mysql'
import { MySqlQuerier } from 'nukak'
MySqlQuerier is exported from the adapter package, not from core nukak.
MySqlDialect
import { MySqlDialect } from 'nukak-mysql'
Rarely needed directly; used internally by the adapter.

Shows full setup: define a User entity with decorators, create a MySQL connection, instantiate the adapter and querier, then run a query using the repository pattern.

import { MySqlAdapter, MySqlQuerier } from 'nukak-mysql'; import { Entity, PrimaryKey, Property, QueryContext } from 'nukak'; import { createConnection } from 'mysql2/promise'; @Entity({ tableName: 'users' }) class User { @PrimaryKey() id!: number; @Property() name!: string; @Property() email!: string; } async function main() { const connection = await createConnection({ host: process.env.DB_HOST ?? 'localhost', user: process.env.DB_USER ?? 'root', password: process.env.DB_PASSWORD ?? '', database: process.env.DB_NAME ?? 'test', }); const querier = new MySqlQuerier(connection); const adapter = new MySqlAdapter(querier); const ctx = new QueryContext(adapter); const userRepo = ctx.getRepository(User); const users = await userRepo.findMany({ $select: { name: true, email: true }, $where: { email: { $endsWith: '@example.com' } }, $limit: 10, }); console.log(users); await connection.end(); } main().catch(console.error);
Debug
Known issues
breakingnukak-mysql requires nukak core ^1.8.1. Using an older core version will cause runtime errors or missing features.
fix
Update nukak to version ^1.8.1 or later.
affects: <1.8.1
gotchaThe package is pure ESM. It cannot be imported using CommonJS require(). Attempts will throw ERR_REQUIRE_ESM.
fix
Use import syntax or dynamic import(). Set your project to type: module in package.json.
affects: >=1.0.0
gotchaTypeScript decorators require experimentalDecorators and emitDecoratorMetadata to be enabled in tsconfig.json.
fix
Add 'experimentalDecorators': true and 'emitDecoratorMetadata': true to your tsconfig.json.
affects: >=1.0.0
deprecatedThe MySqlAdapter constructor expects a MySqlQuerier instance. Passing a raw connection will fail.
fix
Create a MySqlQuerier first: new MySqlQuerier(connection), then pass that to MySqlAdapter.
affects: >=1.0.0
gotchamysql2 driver version ^2.3.3 is required. Using older mysql2 may cause compatibility issues with prepared statements or type casting.
fix
Update mysql2 to ^2.3.3 or later.
affects: <2.3.3
Errors
Common errors & fixes
ERR_REQUIRE_ESM: require() of ES Module /path/to/nukak-mysql/index.mjs not supported
Attempting to import an ESM-only package with CommonJS require().
fix
Use import syntax: import { MySqlAdapter } from 'nukak-mysql'
Error: MySqlAdapter requires a MySqlQuerier instance. Received: object
Passing the raw mysql2 connection object directly to MySqlAdapter instead of wrapping it in MySqlQuerier.
fix
Create a MySqlQuerier first: new MySqlQuerier(connection), then pass it to MySqlAdapter.
Cannot find module 'nukak' or its corresponding type declarations
Missing nukak core package or incorrect import path.
fix
Run: npm install nukak
Property 'findMany' does not exist on type 'Repository<User>'
Using an outdated version of nukak that doesn't expose repository methods properly.
fix
Update both nukak and nukak-mysql to their latest versions.
Upgrade
Version history
1.9.1latest on npm
Audit
Dependencies
nukakrequiredCore ORM library providing query building, entity management, and runtime
mysql2requiredMySQL database driver used for connections and queries
Agent activity
12 hits · last 30 days
node
6
Bingbot
5
Resources
nukak-mysql — npm install nukak-mysql · libregistry