v1.3.0Now with automatic versioning

A Modern, Type-Safe ORM for Bun

Lightweight, feature-rich ORM designed for performance and developer experience. Write once, run on PostgreSQL, MySQL, or SQLite.

Terminal
$ bun add stabilize-orm

Everything you need to build with confidence

Stabilize provides a complete toolkit for modern database operations with performance and developer experience at its core.

Unified API
Write once, run on PostgreSQL, MySQL, or SQLite with a single, consistent API.
Type-Safe Models
Programmatic model definitions with DataTypes enum for database-agnostic schemas.
Query Builder
Fluent, chainable API for building complex queries with joins, filters, and pagination.
Advanced Relationships
Define OneToOne, ManyToOne, OneToMany, and ManyToMany relationships with ease.

Simple, powerful, and expressive

Build complex database operations with clean, intuitive code that scales with your application.

Define Models
import { defineModel, DataTypes, RelationType } from "stabilize-orm";
const User = defineModel({
tableName: "users",
versioned: true,
columns: {
id: { type: DataTypes.Integer, required: true },
email: { type: DataTypes.String, length: 100, required: true },
name: { type: DataTypes.String, length: 255 },
createdAt: { type: DataTypes.DateTime, default: () => new Date() },
},
relations: [
{
type: RelationType.OneToMany,
target: () => Post,
property: "posts",
foreignKey: "userId",
},
],
hooks: {
beforeCreate: (entity) => console.log(`Creating: ${entity.email}`),
afterUpdate: (entity) => console.log(`Updated: ${entity.id}`),
},
});

One API, three databases

Switch between PostgreSQL, MySQL, and SQLite without changing your code. Stabilize handles the differences for you.

PostgreSQL

Full support for advanced PostgreSQL features

MySQL

Complete MySQL compatibility and optimization

SQLite

Lightweight SQLite support for embedded databases

Configuration Example

// config/database.ts
import { DBType, type DBConfig } from "stabilize-orm";
const dbConfig: DBConfig = {
type: DBType.Postgres, // or DBType.MySQL, DBType.SQLite
connectionString: process.env.DATABASE_URL || "postgres://user:password@localhost:5432/mydb",
retryAttempts: 3,
retryDelay: 1000,
};
export default dbConfig;