Skip to main content

Database ORMs

Which ORM lets you write SQL-close queries, handle schema migrations, and deploy to the edge?

Selection Criteria

The ORM sits in the data-repositories layer of hexagonal architecture — it implements the ports that domain logic depends on. Wrong choice here ripples through every query, every migration, every deploy.

CriteriaWhy It MattersWeight
Type safetySchema changes caught at compile time, not productionMust have
SQL proximityReadable queries, no magic. Debug what you wroteMust have
Edge executionVercel Edge, Cloudflare Workers — no heavy runtimeMust have
Migration toolingDeclarative schema changes, rollback supportMust have
Multi-tenant scopingorganisationId filtering composable into every queryMust have
Monorepo supportWorks cleanly in Nx workspace with shared schemaShould have
EcosystemCommunity health, plugin ecosystem, active maintenanceShould have

Candidates

DrizzlePrismaKyselySQLd
Type safetyFull — schema-as-code in TSFull — generated client from schema fileFull — query builder with inferencePartial — libSQL typed
SQL proximityHigh — reads like SQLLow — custom query APIHigh — query builderHigh — raw SQL
Edge runtimeYes — lightweightNo — binary engine requiredYes — lightweightYes — SQLite-based
Migrationsdrizzle-kit — declarativeprisma migrate — matureManual or third-partyManual
Multi-tenantComposable .where() chainsMiddleware or $extendsComposable .where() chainsPer-DB isolation
MonorepoClean — just TS filesPainful — nx workspace issuesClean — just TS filesN/A
EcosystemGrowing fast, Drizzle StudioLargest, Prisma StudioSmaller, focusedTurso-specific

Our Choice

Drizzle — SQL-close, edge-native, schema-as-TypeScript-code. No binary engine, no code generation step, composes naturally with organisationId scoping in the ApplicationContext pattern.

Prisma was the previous choice. The migration cost is real but the edge constraint and monorepo friction made it unavoidable.

Context