Comparison
This page helps you choose between kern-orm and other TypeScript ORMs and query builders for PostgreSQL: Drizzle ORM, Kysely, Prisma ORM, and Orchid ORM. It compares Drizzle ORM 0.45.4, Kysely 0.29.8, Prisma ORM 7.10.1, Orchid ORM 1.78.47, and kern-orm 0.17, as of November 2026, by their documentation and sources, which each row links.
When kern-orm fits
Choose kern-orm when your application on PostgreSQL needs:
- Records with their related records, typed and loaded in one SQL statement.
- Transactions that the functions it calls join without a transaction object passed to them.
- A PostgreSQL schema per tenant, served by one
dbwith the same table definitions and queries. - Tests that each run in a transaction that rolls back, including the transactions of the tested code.
Consider another library when you need what kern-orm does not have:
- Databases other than PostgreSQL.
- Migrations generated from your table definitions: with kern-migrations, you write each migration with helpers, SQL, or TypeScript.
- Joins, and relations through other relations or through a join table.
- A stable API: kern-orm is in early development, and its API changes between minor versions.
At a glance
| kern-orm | Drizzle ORM | Kysely | Prisma ORM | Orchid ORM | |
|---|---|---|---|---|---|
| Related records in one statement | Built in | Built in | Requires a subquery per relation | Behind a preview feature | Built in |
| Transactions without passing them around | Built in, from kern-db | Not supported | Not supported | Not supported | Built in |
One db for a schema per tenant | Built in | Not supported | An instance per schema | A client per schema | Built in |
| Tests in transactions that roll back | Built in, from kern-db | Requires passing a transaction to the tested code | Requires passing a transaction to the tested code, which cannot nest one | Through jest-prisma | Built in |
| Rows of SQL text | Decoded by declared types, from kern-db | Typed by an unchecked type argument | Typed by an unchecked type argument | Typed by an unchecked type argument, or generated in preview | Typed by an unchecked type argument |
| Migrations | Written, with kern-migrations | Generated | Written | Generated | Written or generated |
| Checking table definitions against the database | A check of compatibility | Not supported | A check of generated types, through kysely-codegen | A schema diff | Not found |
kern-orm takes transactions, test transactions, and queries of SQL text from kern-db, which it installs, and migrations from kern-migrations, which you install beside it; see Kern Libraries.
Related records in one statement
With kern-orm, select the related records of each row in the callback of select, at any depth: the query loads them in one SQL statement, with the shape of the result inferred; see Related Records.
- Drizzle ORM: its relational queries,
db.query, load relations in one statement ofLEFT JOIN LATERALsubqueries (source). - Kysely: it has no relations; nest a correlated subquery of each relation in
jsonArrayFromorjsonObjectFrom(docs). - Prisma ORM:
includeloads relations in one statement only with the preview featurerelationJoins, and in a query per table otherwise (docs). - Orchid ORM: relations selected in
selectload in one statement ofLEFT JOIN LATERALsubqueries (docs).
Transactions without passing them around
With kern-orm, the queries in the callback of db.$transaction, including those of the functions it calls, run in the transaction; see Transactions.
- Drizzle ORM: only the queries of the
txthattransactionpasses to its callback run in the transaction (source). - Kysely: only the queries of the transaction object run in the transaction (source).
- Prisma ORM: only the queries of the
txthat$transactionpasses to its callback run in the transaction (docs). - Orchid ORM: the queries of
dbin the callback of$transactionrun in the transaction (docs).
A schema per tenant
With kern-orm, pass bindSchema a function that returns the PostgreSQL schema of the current request, and one db serves every tenant; tables of a shared schema stay in it; see PostgreSQL schemas and Multiple Schemas.
- Drizzle ORM: a table belongs to the schema of its definition, with no override at runtime (source).
- Kysely:
withSchemagives an instance that queries the tables in a schema, and the shared tables are qualified in the types of the database (docs). - Prisma ORM: a model with
@@schemabelongs to that schema (docs), and a model without it to the default schema of the client, which theschemaoption ofPrismaPgsets, so a schema per tenant requires a client per schema (source). - Orchid ORM: the
schemaoption oforchidORMtakes a function, called for every query (docs).
Tests in transactions that roll back
With kern-orm, run each test in a transaction that rolls back, with node:test, bun:test, or Vitest; the tested code queries the db of your application, and its transactions run as nested transactions; see Testing.
- Drizzle ORM: it has no test helper; the tested code joins a transaction of a test only through a
txpassed to it, and its transactions in it are savepoints (source). - Kysely: it has no test helper; the tested code joins a transaction of a test only through a transaction object passed to it, and cannot start a transaction in it (source).
- Prisma ORM: its guide of integration tests deletes the data after the tests (docs); jest-prisma, a library of its own, runs each Jest test in a transaction that rolls back.
- Orchid ORM:
testTransactionruns each test in a transaction that rolls back, and the transactions of the tested code in it as savepoints (docs).
Rows of SQL text
With kern-orm, pass the types of the fields to a query of SQL text: it decodes each field from its column, and rejects a result without the column; see SQL Statements.
- Drizzle ORM, Kysely, and Orchid ORM:
execute,sql, and$querytype the rows by a type argument that nothing checks (Drizzle ORM, Kysely, Orchid ORM). - Prisma ORM:
$queryRawtypes the rows by a type argument that nothing checks (docs), and its preview feature TypedSQL generates the types of the rows of a SQL file from the database (docs).
Migrations
With kern-migrations, write each migration with schema helpers, SQL, or TypeScript functions, apply it, and test it; see Migrations.
- Drizzle ORM:
drizzle-kit generategenerates migrations from your table definitions (source). - Kysely: its
Migratorapplies migrations that you write (docs). - Prisma ORM:
prisma migrate devgenerates SQL migrations from your models (docs). - Orchid ORM: you write migrations, or generate them from your tables with
db g(docs).
Checking table definitions against the database
With kern-orm, check in a test that the database has what your table definitions rely on, such as their columns, keys, and foreign keys, while it may have more, such as other nullable columns; see Tables that match the database.
- Drizzle ORM:
drizzle-kit checkchecks the files of its migrations, not the database (source). - Kysely: kysely-codegen, a library of its own, generates TypeScript types from the database, and its
--verifyfails when the generated file is out of date. - Prisma ORM:
prisma migrate diffwith--exit-codefails when the structure of the database differs from your models in anything that Prisma ORM supports, such as an extra column (docs). - Orchid ORM: this comparison has not found such a check.