Registry / database / tspace-mysql

tspace-mysql

JSON →
library1.9.1jsnpmunverified

Tspace MySQL is a promise-based ORM for Node.js with full TypeScript support, providing type safety, model-based CRUD, schema migrations, relationships, soft deletes, caching, and a job queue. Current stable version is 1.9.1. It supports MySQL, MariaDB, Postgres, SQLite, and MongoDB (experimental). Key differentiators include built-in validation, a CLI for migrations and model generation, decorators for clean code, and support for nested relations. Releases follow a regular cadence with TypeScript peer dependency >=5.6.2. Compared to Sequelize or TypeORM, it offers a more opinionated repository pattern and includes caching (in-memory and Redis) and a queue out of the box.

npm install tspace-mysql
INSTALL
IMPORT
SIG · TSPACE-MYSQL
T
tspace-mysql
databasejavascriptv1.9.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.

TspaceMysql
import { TspaceMysql } from 'tspace-mysql'
const TspaceMysql = require('tspace-mysql')
Library is ESM-first; CommonJS require() may break with newer versions.
Model
import { Model } from 'tspace-mysql'
import Model from 'tspace-mysql'
Model is a named export, not default.
Table
import { Table } from 'tspace-mysql/decorators'
import { Table } from 'tspace-mysql'
Decorators are exported from 'tspace-mysql/decorators' subpath.

Initializes a TspaceMysql connection, defines a User model with a decorator, syncs schema, creates a record, and logs it.

import { TspaceMysql, Model, Column } from 'tspace-mysql'; const db = new TspaceMysql({ host: process.env.DB_HOST ?? 'localhost', user: process.env.DB_USER ?? 'user', password: process.env.DB_PASS ?? '', database: process.env.DB_NAME ?? 'test', }); class User extends Model { @Column({ type: 'varchar', length: 100 }) name: string = ''; } await db.connect(); await db.sync(); // syncs schema const user = await User.create({ name: 'Alice' }); console.log(user); await db.close();
Debug
Known issues
breakingVersion 2.x removed support for CommonJS require() – ESM imports only.
fix
Use import syntax or upgrade TypeScript module resolution to Node16+.
affects: >=2.0.0
deprecatedThe 'sync' method is deprecated in favor of explicit migrations.
fix
Use `db.migrate()` or CLI `tspace-mysql migrate` instead.
affects: >=1.8.0
gotchaDecorators require TypeScript >=5.6.2 and experimentalDecorators enabled.
fix
Set `experimentalDecorators: true` in tsconfig.json.
affects: >=1.0.0
gotchaMongoDB support is experimental and may break with complex queries.
fix
Use only MySQL/MariaDB/Postgres for production.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'tspace-mysql'
Package not installed or misconfigured path.
fix
Run `npm install tspace-mysql` and ensure import path is correct.
TypeError: tspace_mysql_1.TspaceMysql is not a constructor
CommonJS require() used with ESM-only package.
fix
Use `import { TspaceMysql } from 'tspace-mysql'` instead.
SyntaxError: Unexpected token '@'
Decorators used without enabling TypeScript experimentalDecorators.
fix
Add `"experimentalDecorators": true` to tsconfig.json.
Upgrade
Version history
1.9.1latest on npm
Audit
Dependencies
typescriptoptionalPeer dependency for decorators and type safety
mysql2requiredMySQL driver (automatic peer dep when using MySQL)
Agent activity
23 hits · last 30 days
node
18
Meta
2
OpenAI (training)
1
Resources
tspace-mysql — npm install tspace-mysql · libregistry