Registry / database / tyno-orm

tyno-orm

JSON →
library1.0.3jsnpmunverified

A lightweight TypeScript ORM for MySQL, inspired by ThinkPHP's chaining syntax. Version 1.0.3 provides a fluent query builder with chainable where, join, order, paginate, and union methods. Automatically generates table names from class names (camelCase to snake_case). Supports timestamps, raw SQL, and debugging via fetchSql. Differentiates itself by minimal configuration and familiar PHP-style chaining for TypeScript/Node.js developers. Ships TypeScript types. Current version stable with monthly releases.

npm install tyno-orm
INSTALL
IMPORT
SIG · TYNO-ORM
T
tyno-orm
databasejavascriptv1.0.3
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.

Db
import { Db } from 'tyno-orm'
import Db from 'tyno-orm'
Default export does not exist; use named import.
Model
import { Model } from 'tyno-orm'
const { Model } = require('tyno-orm')
Package is ESM-only; CommonJS require will fail. Use ES imports.
Query
import type { Query } from 'tyno-orm'
import { Query } from 'tyno-orm'
Query is a type, not a runtime value. Use type import for TypeScript.

Shows configuring a database connection, defining a model, and querying users with a where clause and limit.

import { Db, Model } from 'tyno-orm'; Db.setConfig({ default: { host: 'localhost', port: 3306, user: 'root', password: process.env.DB_PASSWORD ?? '', database: 'my_db', prefix: 'ty_', } }); class User extends Model { static table = 'user'; } async function main() { const users = await User.where('status', 1).limit(10).select(); console.log(users); } main().catch(console.error);
Debug
Known issues
breakingESM-only package; require() will fail with 'ERR_REQUIRE_ESM'
fix
Use import syntax; if using CommonJS, use dynamic import or transpile.
affects: >=1.0.0
breakingModel must be subclassed; direct instantiation throws error
fix
Define a class that extends Model (e.g., class User extends Model {}) before calling static methods.
affects: >=1.0.0
gotchawhere() with two arguments defaults to '=' operator; three arguments needed for operators like '>', '<'
fix
Use where('field', 'operator', value) for non-default operators.
affects: >=1.0.0
gotchaTable prefix is applied to all queries including raw SQL; raw queries must include prefix manually
fix
When using whereRaw or orderRaw, prepend the prefix if needed (e.g., 'ty_' + 'user').
affects: >=1.0.0
deprecatedfetchSql() may be removed in future versions; use toSql() and getBindings() instead
fix
Use query.toSql() and query.getBindings() for SQL debugging.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Class extends value undefined is not a constructor or null
Importing Model incorrectly or using CommonJS require
fix
Use import { Model } from 'tyno-orm' (ESM) and ensure the package is installed.
Error: Cannot find module 'mysql2'
Missing peer dependency mysql2
fix
Run npm install mysql2 alongside tyno-orm.
TypeError: User.where is not a function
User class does not extend Model, or Model is incorrectly imported
fix
Ensure class User extends Model and import Model as named export.
SQL syntax error near '?' at line 1
Using raw SQL with user input without parameterization
fix
Use where(clause, params) or whereRaw with positional placeholders (?) instead of string interpolation.
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies
mysql2requiredRequired as peer dependency for MySQL database connection
Agent activity
41 hits · last 30 days
node
36
Meta
2
Bingbot
2
OpenAI (training)
1
Resources
tyno-orm — npm install tyno-orm · libregistry