Skip to content

Migrating from Drizzle

This guide helps you transition from Drizzle ORM to db-semantic-planner. Both tools embrace a SQL-first philosophy, but dbsp adds a semantic planning layer that automates query strategy decisions and provides full observability.

Key Differences

ConceptDrizzledbsp
Schema definitionpgTable() (TypeScript)schema() (TypeScript)
Relation loadingwith: { posts: true } or manual joins.include('posts') (auto-strategy)
Query buildingdb.select().from(users)orm.select('users')
Filteringeq(users.active, true)eq('active', true)
Observability.toSQL().dump() (plan + SQL + params)
Join strategyManual choiceAutomatic (EXISTS vs JOIN vs lateral)
Multi-tenantManual schema prefix.withSchema('tenant') built-in

Quick Translation Reference

Drizzle → dbsp

Drizzledbsp
db.select().from(users)orm.select('users').all()
db.select().from(users).where(eq(users.active, true))orm.select('users').where(eq('active', true)).all()
db.insert(users).values(data)orm.insert('users').values(data).execute()
db.update(users).set(data).where(...)orm.update('users').set(data).where(...).execute()
db.delete(users).where(...)orm.delete('users').where(...).execute()
.toSQL().dump()

Released under the MIT License.