v3.2.0Runs on Node.js and Bun

Build faster with Stabilize ORM

A type-safe ORM for Bun that runs the same models against PostgreSQL, MySQL, SQLite, SQL Server, and MongoDB. Define models, run migrations and query data through one interface.

PostgreSQL
MySQL
SQLite
SQL Server
MongoDB

Features

Everything you need

A complete toolkit for building production apps with type-safe database access.

Core

Unified API

One codebase runs on PostgreSQL, MySQL, SQLite, SQL Server, and MongoDB.

Type-Safe Models

Full TypeScript inference with the DataTypes enum.

Relationships

OneToOne, ManyToOne, OneToMany, ManyToMany.

Soft Deletes

Mark deleted without removing. Recover anytime.

Advanced

Versioning

History tracking with time-travel and rollback.

Transactions

Atomic operations with automatic rollback.

Optimistic Locking

Detect concurrent modifications automatically.

Query Scopes

Reusable filters for complex queries.

Tooling

CLI (31 commands)

Generate models, migrations, seeds and APIs, on SQL or MongoDB.

Backup & Restore

Database backup with a single command.

API Generation

Scaffold REST routes from model definitions.

Caching Layer

Cache-aside and write-through, on Redis or in process.

Code

Clean, intuitive, powerful

Write database operations with expressive, type-safe code.

models.ts
import { defineModel, DataTypes } from "stabilize-orm";
const User = defineModel({
tableName: "users",
timestamps: { createdAt: "createdAt", updatedAt: "updatedAt" },
columns: {
id: { type: DataTypes.STRING, required: true, unique: true },
email: { type: DataTypes.STRING, length: 255, required: true },
name: { type: DataTypes.STRING, length: 100 },
isActive: { type: DataTypes.BOOLEAN, defaultValue: true },
deletedAt: { type: DataTypes.DATETIME, softDelete: true },
},
scopes: {
active: (qb) => qb.where("isActive = ?", true),
},
});

Databases

One API, five databases

Switch between PostgreSQL, MySQL, SQLite, SQL Server, and MongoDB by changing a single config line. Your code stays the same.

PostgreSQL

Full support for advanced features, JSONB, and connection pooling.

MySQL

Complete MySQL compatibility with connection pool management.

SQLite

Lightweight embedded database perfect for development and testing.

SQL Server

Microsoft SQL Server, with MERGE-based upserts and IDENTITY keys.

MongoDB

Document storage through the same repository API, with joins replaced by withRelations().

Sponsors

Supported by

Stabilize is developed with support from the companies below.