ormDB + TypeORM
What This Adapter Does
ormDB is a relational database engine written in Rust that replaces PostgreSQL, MySQL, and SQLite as the actual database underneath your application. The @ormdb/typeorm-adapter package connects TypeORM’s entity system and repository pattern to ormDB, so your decorated entity classes, relations, and repositories continue to work while the database resolves object graphs natively.
TypeORM’s relations option on find methods tells the ORM which related entities to load. With a SQL database, TypeORM issues separate JOIN queries or additional SELECT statements for each relation, often causing N+1 problems. ormDB receives the entire relation tree as a graph-fetch request and returns the complete object graph in a single round-trip.
Quick Setup
Install the adapter:
npm install @ormdb/typeorm-adapter
Configure your data source:
import { DataSource } from 'typeorm'
import { OrmDBDriver } from '@ormdb/typeorm-adapter'
const AppDataSource = new DataSource({
type: 'ormdb',
driver: OrmDBDriver,
url: process.env.ORMDB_URL,
entities: [User, Post, Comment],
synchronize: false,
})
Your existing entities and queries work unchanged:
@Entity()
export class User {
@PrimaryColumn()
id: string
@Column()
name: string
@OneToMany(() => Post, (post) => post.author)
posts: Post[]
}
// Single round-trip graph fetch
const users = await userRepository.find({
relations: {
posts: {
comments: true,
tags: true,
},
},
})
What Changes, What Stays the Same
Stays the same: Entity decorators (@Entity, @Column, @OneToMany, etc.), the repository pattern, find methods with relations, EntityManager operations, and transaction wrappers.
Changes: The database engine. Nested relations options become single-round-trip graph fetches. Migrations gain A-D safety grading. Built-in vector search, geo search, full-text search, and change streams replace the need for database extensions. TypeORM with ormDB is a great fit for TypeScript projects.
Removed: Raw SQL via query(), createQueryBuilder().getQuery(), and any direct SQL string execution. All queries must use TypeORM’s entity and repository APIs. See how ormDB compares to databases TypeORM traditionally connects to: PostgreSQL and SQLite.
Frequently Asked Questions
Do TypeORM's eager and lazy relations work with ormDB?
Yes. Eager relations are resolved via ormDB's graph-fetch in a single round-trip instead of multiple SQL joins. Lazy relations trigger a graph fetch on access. Both patterns are fully supported.
Does the QueryBuilder work?
The adapter supports TypeORM's QueryBuilder for standard operations like select, where, orderBy, and join. Raw SQL strings passed to the QueryBuilder are not supported because ormDB does not use SQL.
Can I use TypeORM's migration system with ormDB?
Yes. The adapter intercepts TypeORM's migration runner and routes changes through ormDB's migration engine, which grades each migration from A (safe) to D (destructive).
What about TypeORM's support for multiple databases?
The adapter replaces the connection to a single database engine. If your application uses multiple TypeORM connections, each can be independently configured to use ormDB or a traditional SQL database.
Is the adapter production-ready?
The adapter is in beta. ormDB itself is in Alpha v0.1.0. It is suitable for development and testing today, with production readiness expected as ormDB matures.