Registry / database / stabilize-orm

stabilize-orm

JSON →
library2.1.0jsnpmunverified

Stabilize ORM v2.1.0 is a modern, type-safe ORM for Bun (primary), Node.js >=18, and Deno, supporting SQLite, MySQL, PostgreSQL, Redis caching, optimistic locking, cursor pagination, and a full-featured query builder. Released under MIT, primarily maintained by ElectronSz with monthly releases. Key differentiators: programmatic model definitions, automatic versioning/travel, built-in migration CLI (stabilize-cli), soft deletes, lifecycle hooks, and pluggable logging. Compared to other Bun ORMs (e.g., Drizzle, Prisma), Stabilize emphasizes a unified API across databases, automatic retry logic, and bundled Redis cache layer.

npm install stabilize-orm
INSTALL
IMPORT
SIG · STABILIZE-ORM
S
stabilize-orm
databasejavascriptv2.1.0
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.

Stabilize
import { Stabilize } from 'stabilize-orm'
const { Stabilize } = require('stabilize-orm')
ESM-only since v2. No CommonJS support.
defineModel
import { defineModel } from 'stabilize-orm'
import defineModel from 'stabilize-orm'
Named export, not default.
DataTypes
import { DataTypes } from 'stabilize-orm'
import { DataType } from 'stabilize-orm'
Export is 'DataTypes' (plural).
StabilizeLogger
import { StabilizeLogger } from 'stabilize-orm'
StabilizeError
import { StabilizeError } from 'stabilize-orm'

Initializes a SQLite in-memory database, defines a User model, synchronizes schema, creates a record, and queries it.

import { Stabilize, defineModel, DataTypes } from 'stabilize-orm'; const db = new Stabilize({ database: { type: 'sqlite', path: ':memory:', }, }); const User = defineModel({ tableName: 'users', columns: { id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true }, name: { type: DataTypes.STRING, required: true }, email: { type: DataTypes.STRING, required: true, unique: true }, }, timestamps: true, softDelete: false, }); await db.sync(); // creates table const user = await User.create({ name: 'Alice', email: 'alice@example.com' }); console.log(user.id); // 1 const users = await User.findAll({ where: { email: 'alice@example.com' } }); console.log(users.length); // 1 await db.close();
Debug
Known issues
breakingv2.0.0 drops support for Node.js <18. The minimum Node version is now 18.
fix
Upgrade Node.js to >=18.
affects: >=2.0.0
breakingv2.0.0 replaces the old model definition API (class-based) with the new `defineModel` function. Old `Model.extend()` patterns no longer work.
fix
Use `defineModel({...})` instead of class-based models.
affects: >=2.0.0 <3.0.0
deprecatedThe `query()` method is deprecated in v2.1.0 in favor of the new `findAll` and `findOne` methods with the query builder.
fix
Replace `db.query('SELECT * FROM users')` with `User.findAll()` or use the query builder API.
affects: >=2.1.0
gotchaRedis caching requires the `bun` runtime or a Node.js environment with a compatible Redis client. Using Redis with Node.js may require additional polyfills.
fix
Ensure you are using Bun or install a Redis adapter (not provided out-of-the-box for Node.js).
affects: >=2.0.0
gotchaSoft delete behavior is model-level: you must enable `softDelete: true` in the model definition to get the `deletedAt` column and filtered queries by default.
fix
Add `softDelete: true` to model config if you want soft delete; otherwise deleted records are hard-deleted.
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: Stabilize is not a constructor
Using default import instead of named import
fix
Change to `import { Stabilize } from 'stabilize-orm'`
Cannot find module 'stabilize-orm' or its corresponding type declarations.
TypeScript does not recognize the module; types are included but path resolution is missing
fix
Ensure your tsconfig.json has `moduleResolution: 'node'` or `'nodenext'` and install the package (`npm install stabilize-orm`)
Uncaught Error: Model 'users' already defined
Calling `defineModel` with the same tableName twice
fix
Ensure each model is defined only once, or use a singleton pattern per model definition
Upgrade
Version history
2.1.0latest on npm
Audit
Dependencies
bunrequiredpeer dependency for runtime features like file I/O and SQLite driver
Agent activity
15 hits · last 30 days
node
12
Meta
2
OpenAI (training)
1
Resources
stabilize-orm — npm install stabilize-orm · libregistry