Registry / database / typed-orm

typed-orm

JSON →
library1.39.1jsnpmunverified

A structurally-typed MySQL query builder and ORM for TypeScript, leveraging advanced type system features for compile-time query safety. Version 1.39.1 (latest) is the final release; the project is deprecated with no further updates. Key differentiator: focus on structural typing (not nominal) for precise column type tracking, but superseded by the @squill family of packages (squill, mysql-5.7, sqlite3-browser) which offer similar safety with broader database support.

npm install typed-orm
INSTALL
IMPORT
SIG · TYPED-ORM
T
typed-orm
databasejavascriptv1.39.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.

Table
✓ import { Table } from 'typed-orm'
✗ const { Table } = require('typed-orm')
ESM-only; CJS require breaks because package uses export assignments.
SelectQuery
✓ import { SelectQuery } from 'typed-orm'
✗ import { SelectQuery } from 'typed-orm/lib/SelectQuery'
Do not use internal paths; they are not part of the public API and may change.
WithRow
✓ import { WithRow } from 'typed-orm/row'
✗ import { WithRow } from 'typed-orm'
Row utilities are in a separate subpath export; direct import from root may be undefined.

Defines a table with structurally typed columns and performs an insert using the typed query builder.

import { Table, Column, InsertQuery } from 'typed-orm'; const myTable = Table('my_table', { id: Column<number>({ primaryKey: true }), name: Column<string>({ dataType: 'VARCHAR(255)' }), }); async function insertRow(connection: any) { const query = InsertQuery.into(myTable, ['id', 'name']) .values({ id: 1, name: 'Alice' }) .toSql(); await connection.query(query.sql, query.values); }
Debug
Known issues
deprecatedThe package is deprecated and should not be used for new projects.
fix
Migrate to @squill/squill and corresponding database-specific packages.
affects: >=1.0.0
breakingChange in primary key handling between v1.0 and v1.1: primaryKey property changed from boolean to object with autoIncrement option.
fix
Update column definitions to { primaryKey: true } to { primaryKey: { autoIncrement: false } } or similar.
affects: >=1.0.0 <1.1.0
gotchaMethod .whereEq() does not narrow column type literals (e.g., 'test' remains string, not literal 'test'), which differs from typical tagged literal types.
fix
Use explicit type assertions if literal type narrowing is required.
affects: >=1.0.0
gotchaCase-insensitive collations cause .whereEq to match case-insensitively; may return rows with different casing.
fix
Ensure columns have case-sensitive collation or use BINARY keyword in comparisons.
affects: >=1.0.0
breakingRemoval of deprecated non-exported symbols (e.g., internal helper interfaces) in v1.30 — imported via deep paths broke.
fix
Only import public API from the root or documented subpath exports (e.g., 'typed-orm/row').
affects: >=1.30.0
Errors
Common errors & fixes
Cannot find module 'typed-orm'
Missing npm install or package name typo
fix
Run 'npm install typed-orm' and ensure import path is correct.
Type 'number' is not assignable to type 'never'
Column type inference failure when using .values() with mismatched column order
fix
Explicitly specify column names in order matching the insert array, e.g., .values({ id: 1 }) instead of positional values.
Property 'sql' does not exist on type 'Query'
Trying to access .sql or .values before calling .toSql()
fix
Call .toSql() on the query object first to get { sql, values }.
Upgrade
Version history
1.39.1latest on npm
Audit
Dependencies
mysql2requiredMySQL database driver for runtime connections
typescriptoptionalPeer dependency for type safety; version >=3.8 required for structural typing features
Agent activity
21 hits · last 30 days
node
18
Amazon
1
OpenAI (training)
1
Resources
typed-orm — npm install typed-orm · libregistry