Registry / database / loke-mysql-orm

loke-mysql-orm

JSON →
library1.11.0jsnpmunverified

Lightweight MySQL data mapper ORM for Node.js (v1.11.0). Provides a simple API for defining models with typed columns, associations, and automatic query building. Supports promises, repository pattern, and custom queries. Released under MIT. Differentiator: minimalistic design with no heavy dependencies, focuses on data mapping rather than full ORM.

npm install loke-mysql-orm
INSTALL
IMPORT
SIG · LOKE-MYSQL-ORM
L
loke-mysql-orm
databasejavascriptv1.11.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.

create
const { create } = require('loke-mysql-orm')
import { create } from 'loke-mysql-orm'
CommonJS only - ESM not supported.
db.table
const repo = db.table('Pets', schema)
const repo = db.Table('Pets', schema)
Method is lowercased 'table'.
db.Text
description: db.Text
description: Text
Text is a constructor on the db instance, not globally available.

Creates a database connection, defines a Pet model, and queries by name.

const { create } = require('loke-mysql-orm'); const db = create('mysql://root:password@localhost/mydb'); const petRepo = db.table('Pets', { name: { type: String, defaultValue: () => 'Untitled' }, description: db.Text }); petRepo.find({ name: 'Rex' }) .then(pets => { console.log(pets); }) .catch(err => console.error(err));
Debug
Known issues
gotchaProperties defined in schema default to NOT NULL unless nullable option set.
fix
Explicitly add nullable: true to allow NULL values.
affects: >=1.0.0
gotchaAssociations via array syntax (e.g., pets: [petRepo]) create one-to-many relations; only works with instance arrays.
fix
Ensure the referenced repository is defined before the parent.
affects: >=1.0.0
gotchaUsing db.String, db.Number, etc. is deprecated in favor of { type: String } style.
fix
Use schema objects with type property.
affects: >=1.8.0
gotchaQueries are promises - missing .catch() can cause unhandled rejections.
fix
Always attach a .catch() handler or use async/await with try/catch.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: db.create is not a function
Calling create on require'd object incorrectly.
fix
Use const { create } = require('loke-mysql-orm') then create(url);
Error: Table not found: Pets
Table name in code does not match schema table name; table must exist in DB.
fix
Ensure table 'Pets' exists or set autoCreate: true in options.
TypeError: Cannot read property 'table' of undefined
db is undefined because create() failed or wasn't invoked.
fix
Verify database connection URL and call create() before using db.
Upgrade
Version history
1.11.0latest on npm
Audit
Dependencies
mysql2requiredMySQL database driver - uses connection pooling and prepared statements.
Agent activity
6 hits · last 30 days
node
6
Resources
loke-mysql-orm — npm install loke-mysql-orm · libregistry