Registry / database / tiny-mysql-orm

tiny-mysql-orm

JSON →
library1.0.13jsnpmunverified

A lightweight MySQL ORM for Node.js that simplifies database and table creation, as well as insert queries. Currently at version 1.0.13, it supports automatic database/table creation and an insert method with explicit value type handling. Designed for simple use cases with minimal configuration. Lacks advanced query capabilities (select, update, delete), connection pooling, or migration support. Released with an unknown cadence; no recent updates.

npm install tiny-mysql-orm
INSTALL
IMPORT
SIG · TINY-MYSQL-ORM
T
tiny-mysql-orm
databasejavascriptv1.0.13
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.

MysqlHandler
const { MysqlHandler } = require('tiny-mysql-orm');
const MysqlHandler = require('tiny-mysql-orm');
Named export via CommonJS; default import does not exist.
MysqlHandler
import { MysqlHandler } from 'tiny-mysql-orm';
import MysqlHandler from 'tiny-mysql-orm';
ESM named import is supported; default import will fail.
MysqlHandler
const { MysqlHandler } = require('tiny-mysql-orm');
const mysqlHandler = require('tiny-mysql-orm').default;
Do not use .default property.

Shows how to instantiate MysqlHandler with database and table creation, then perform an insert query using explicit value types.

const { MysqlHandler } = require('tiny-mysql-orm'); const host_info = { host: 'localhost', user: 'db_user', password: 'my_password', database: 'test_db' }; const tables = [ { name: 'users', columns: [ { name: 'name', type: 'VARCHAR(128)' }, { name: 'email', type: 'VARCHAR(255)' } ], unique: ['email'] } ]; const handler = new MysqlHandler(host_info, true, tables, false); const query = { table: 'users', columns: ['name', 'email'], values: [ [ { type: 'varchar', value: 'John Doe' }, { type: 'varchar', value: 'john@example.com' } ] ] }; handler.insert(query) .then(result => console.log('Inserted:', result)) .catch(err => console.error('Error:', err));
Debug
Known issues
gotchaThe insert method requires values to be an array of arrays, each inner array containing objects with 'type' and 'value' properties. Type must be a string like 'varchar', 'int', etc.
fix
Ensure values are nested correctly per the example.
affects: >=1.0.0
gotchaWhen 'create_db' or table creation is enabled, the module automatically adds an 'id' column of type 'INT NOT NULL AUTO_INCREMENT' to every table. This may conflict with user-defined columns.
fix
Do not include an 'id' column in the columns array when using auto-creation.
affects: >=1.0.0
gotchaThe module uses synchronous connection creation; it does not support multiple database connections or connection pooling. Each instance uses a single connection.
fix
For pooling, consider using mysql2 with promise wrapper instead.
affects: >=1.0.0
gotchaNo error handling for missing database or table before insert; if table does not exist, the insert will fail with a MySQL error.
fix
Ensure database and tables exist before performing insert operations.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: MysqlHandler is not a constructor
Importing the package as default instead of named export.
fix
Use const { MysqlHandler } = require('tiny-mysql-orm');
Cannot find module 'mysql'
Missing peer dependency 'mysql'.
fix
Run 'npm install mysql'
insert is not a function
Instance not properly created or wrong method name.
fix
Check that MysqlHandler is instantiated with 'new' and call 'insert()' on the instance.
Upgrade
Version history
1.0.13latest on npm
Audit
Dependencies
mysqlrequiredCore dependency for MySQL database connectivity
Agent activity
17 hits · last 30 days
node
14
Meta
2
OpenAI (training)
1
Resources
tiny-mysql-orm — npm install tiny-mysql-orm · libregistry