Registry / database / mysql-records

mysql-records

JSON →
library0.5.11jsnpmunverified

A simple MySQL ORM library providing basic model, link, and primary key support. Currently at version 0.5.11, it is in early development with incomplete documentation and no tests. It targets Node.js and requires a MySQL connection. Not suitable for production use due to its unstable API and lack of features like migrations or query grouping.

npm install mysql-records
INSTALL
IMPORT
SIG · MYSQL-RECORDS
M
mysql-records
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.

mysqlRecords
import mysqlRecords from 'mysql-records'
const mysqlRecords = require('mysql-records')
Package does not export a default CommonJS object; use ESM import.
Model
import { Model } from 'mysql-records'
import Model from 'mysql-records'
Model is a named export, not a default export.
MySQLConnection
import type { MySQLConnection } from 'mysql-records'
import { MySQLConnection } from 'mysql-records'
MySQLConnection is only a type and should be imported as a type.

This example demonstrates connecting to a MySQL database and creating a simple model class to query all users.

import mysqlRecords from 'mysql-records'; import mysql from 'mysql'; const connection = mysql.createConnection({ host: process.env.MYSQL_HOST ?? 'localhost', user: process.env.MYSQL_USER ?? 'root', password: process.env.MYSQL_PASSWORD ?? '', database: process.env.MYSQL_DB ?? 'test' }); const { Model } = mysqlRecords(connection); class User extends Model { static get tableName() { return 'users'; } } async function main() { await connection.connect(); const users = await User.find({}); console.log('Users:', users); await connection.end(); } main().catch(console.error);
Debug
Known issues
gotchaPackage is in early development (0.x) with no tests, incomplete documentation, and unstable API. Breaking changes are expected.
fix
Pin to a specific version and test thoroughly before upgrading.
affects: >=0.0.0
gotchaMySQL connection must be provided explicitly; otherwise, the library throws.
fix
Always pass a valid mysql connection object to mysqlRecords().
affects: >=0.0.0
gotchaThe library uses undocumented internal keys (e.g., __db__) that may change without notice.
fix
Avoid relying on any internal properties; use exposed Model methods.
affects: >=0.0.0
deprecatedThe old callback-based query style using .do() is deprecated. Use the async/await style with .find() directly.
fix
Use async/await or Promises: await Model.find({}) instead of .do() callbacks.
affects: >=0.3.0
Errors
Common errors & fixes
TypeError: mysql_records_1.default is not a function
Using CommonJS require which doesn't get the default export correctly.
fix
Use ESM import: import mysqlRecords from 'mysql-records'
Cannot find module 'mysql'
Missing peer dependency 'mysql'.
fix
Run: npm install mysql
Model is not a constructor
Attempting to instantiate Model directly without calling mysqlRecords(connection).
fix
Use the Model class returned from mysqlRecords(connection), not the one from direct import.
Upgrade
Version history
0.5.11latest on npm
Audit
Dependencies
mysqlrequiredRequired for MySQL database connection and queries
Agent activity
2 hits · last 30 days
node
2
Resources
mysql-records — npm install mysql-records · libregistry