Choosing a Node.js ORM: which queries survive a change of database?

July 8, 2025

I had a set of Oracle queries and wanted to move the business rules they expressed into a Node.js service. Four object-relational mappers (ORMs) made my shortlist: Drizzle, Prisma, Sequelize and TypeORM. All four could return a database row as a JavaScript object. Four questions helped me choose between them.

  1. If I change databases, how much of a business rule can I keep? When a job is rescheduled, its new date takes precedence. I want to maintain that rule in one place. An ORM can translate the operations it understands into each database’s SQL dialect. Any database-specific expression I write myself needs a second look.
  2. Can I maintain the schema and the queries separately? Adding a filter to the employee list should take a change to one query. Recording which skills each employee has changes the structure of the data. I want to know which model definitions, database migrations and callers that second change touches.
  3. When concurrent requests have to wait, what are they waiting for? Three service processes can each open a pool of database connections. They can also contend for the right to write to a single SQLite file. Increasing the pool size only helps if the shortage is actually connections.
  4. Can I recognize the SQL I intend to tune? Consider a report that finds employees earning more than their department average. I might write a correlated subquery. An ORM might make it easier to join employees to their peers and group the result. Both can return the same employees, yet give the optimizer different work to do. I want to inspect the statement, change its shape and check the execution plan against my expectations.

Which parts of a query survive a change of database?

A driver opens connections, sends statements and receives results. A dialect is a database’s particular form of SQL, including how it quotes identifiers and limits a result to ten rows. A working driver gets a statement to the server. The ORM also needs to generate SQL that the server accepts.12

The table uses versions available on July 8, 2025. The database columns indicate connection support. The last four columns compare query APIs using PostgreSQL, which all four supported. A built-in operation gives the ORM a structure it can translate. A SQL fragment inside a template is still handwritten SQL, even when the library quotes column names and binds parameter values for me.

ToolSQLiteMySQLSQL ServerOracleFirst non-null value (COALESCE)Aggregate (AVG)Correlated subquery in a WHERE comparisonFilter employees and keep every department
Drizzle 0.44.212YesYesNoNoHandwritten sql fragment, or expand the rule into or branchesavg(column)3Pass the inner select to gtwith.employees.where4
Prisma 6.1152YesYesYesNo official connectorExpand into OR branches or write SQL to retain the function_avg6Use $queryRaw for the statement. findMany.where has no slot for this subquery.7select.employees.where8
Sequelize 6.37.79YesYesYesYesfn('COALESCE', …) with separate column and value argumentsfn('AVG', col(…))10Inner SELECT in literal, outer query in findAllinclude.where with required: false11
TypeORM 0.3.2412YesYesYesYesParameterized SQL condition in whererepository.average() for a standalone average13Build the inner query with subQuery() and supply SQL for the average and comparisonleftJoinAndSelect with a parameterized join condition13

COALESCE picks the first non-null argument within a row. AVG aggregates values across rows. A library can expose an average as a standalone operation and still give me no way to put that average inside another query.

Oracle narrowed my shortlist to Sequelize and TypeORM. The Oracle team reported testing Sequelize with node-oracledb against Oracle Database 19c and 21c, starting with Sequelize 6.25. TypeORM already had Oracle driver installation instructions in 0.2.45.14

Orange ORM also caught my attention. Its author listed Oracle, SQL Server and SQLite behind the same query API. I could read order.lines.any(line => line.product.contains('broomstick')) and tell which orders it selected. To see how the database would find them, I had to learn that Orange translates .any() into an EXISTS subquery. The database does the filtering. What put me off was having to learn those implicit translations before I could recognize the SQL I wanted to tune.1516

The server version matters too. TypeORM 0.3.24 can generate OFFSET 0 ROWS FETCH NEXT … ROWS ONLY to retrieve one row on SQL Server. That pagination syntax arrived in SQL Server 2012. Against an older instance, even fetching the first row makes a useful test. Likewise, switching the dialect in a Sequelize configuration leaves me responsible for replacing PostgreSQL-specific operations such as Op.iLike.17918

Which API can express a COALESCE predicate?

In the original Stack Overflow question, devklick wrote, “I think I have to group conditions together to replicate this.” The issue was how to preserve the order in which PostgreSQL checks two nullable dates. I adapted that example to a job scheduler. A job has a primary key id, a planned_date and an optional revised_date. In application code the dates are called plannedDate and revisedDate. Which jobs are due by July 8, 2025?19

Jobrevised_dateplanned_dateEffective dateDue?
12025-07-102025-07-01July 10 overrides the original dateNo
2NULL2025-07-08July 8, the planned dateYes
3NULLNULLJanuary 1, 1970, the fallback in this exampleYes

The order of the arguments expresses the business rule. Testing whether either date has passed would incorrectly pick job 1 as well.

SELECT id
FROM job
WHERE COALESCE(revised_date, planned_date, DATE '1970-01-01') <= DATE '2025-07-08';

Prisma: preserve date precedence with explicit branches

Prisma Client generates field filters from the schema. In both 6.8.2 and 6.11.0, lte means “less than or equal to,” and a filter can reference another compatible scalar field of the same model. Here the left operand is a computed date. The generated findMany({ where }) filter has no place to put that function call. With two PostgreSQL date columns, which store a calendar date without a time of day, I can spell out the cases.207

const cutoff = new Date('2025-07-08T00:00:00Z');
const due = await prisma.job.findMany({
  select: { id: true },
  where: {
    OR: [
      { revisedDate: { lte: cutoff } },
      { revisedDate: null, plannedDate: { lte: cutoff } },
      { revisedDate: null, plannedDate: null },
    ],
  },
});

The third branch works because this particular cutoff is later than the fallback. If callers could supply any year, that branch would also have to compare the fallback with the cutoff. To keep the original expression, Prisma offers $queryRaw for parameterized SQL. TypedSQL, then in preview, could generate a typed function from a separate .sql file, including parameter and result types.721

Drizzle: give a handwritten expression a reusable name

Drizzle 0.44.2 has no built-in coalesce(). I can write the expression once and use the query builder for lte, select and where. The string in sql<string> tells TypeScript what result type I expect. It neither validates the database function nor translates its name.22323

import { lte, sql } from 'drizzle-orm';

const fallback = '1970-01-01';
const effectiveDate = sql<string>`coalesce(${job.revisedDate}, ${job.plannedDate}, ${fallback})`;
const dueBy = (day: string) => lte(effectiveDate, day);

const due = await db.select({ id: job.id }).from(job).where(dueBy('2025-07-08'));

To check job 2 alone, I can reuse the predicate as and(eq(job.id, 2), dueBy(day)). Drizzle’s or also lets me express the three branches from the Prisma example.3

📓 Note: Moving this fragment to SQLite takes a look at the data as well as the SQL. Drizzle handles identifier quoting and bound values. Both SQLite and PostgreSQL support COALESCE. Fixed-width YYYY-MM-DD strings in SQLite sort in date order, whereas integer timestamps need matching parameter values. PostgreSQL’s DATE '1970-01-01' literal produces a syntax error on SQLite 3.45.1.2324 See also translating Oracle SQL to MySQL (in Chinese).

Sequelize: pass the function, columns and values separately

Sequelize v6 exposes fn, col and where. col('revised_date') denotes a column reference. Passing 'revised_date' as an ordinary argument to fn would give the function a string value instead. The target database still has to recognize the function name.10

const { col, fn, Op, where } = require('sequelize');

const effectiveDate = fn(
  'COALESCE',
  col('revised_date'),
  col('planned_date'),
  '1970-01-01',
);

const due = await Job.findAll({
  attributes: ['id'],
  where: where(effectiveDate, { [Op.lte]: '2025-07-08' }),
});

On Sequelize 6.37.7 with SQLite, the generated WHERE retained COALESCE and selected jobs 2 and 3. Sequelize also accepts a complete handwritten statement through sequelize.query.25

TypeORM: keep the predicate and bind its parameters

jobRepository is the repository for the job entity, the object through which TypeORM reads and writes jobs. Its query builder accepts a condition with named parameters. I can give the table the alias j and keep the original function and comparison operator.12

const due = await jobRepository.createQueryBuilder('j')
  .select('j.id')
  .where('COALESCE(j.revised_date, j.planned_date, :fallback) <= :day', {
    fallback: '1970-01-01',
    day: '2025-07-08',
  })
  .getMany();

For this date rule, I prefer Sequelize. I can preserve the function call and distinguish columns, values and the comparison in the API. fn still takes a string, so a misspelled name or the wrong number of arguments can reach the database. Drizzle and TypeORM preserve the SQL in a handwritten fragment. Prisma’s branches reproduce the rule but give me more places to edit if the precedence changes.102320

I also considered Knex. Its chained query builder reads much like SQL, but retaining COALESCE in 3.1.0 still meant writing the function call with knex.raw. At the time I also felt I would have an easier time finding examples and discussing queries like this in the other libraries’ communities. Those two considerations took Knex off my shortlist.26

Where should a filter go to keep every parent row?

A department directory should show only employees who work remotely. I still want Design to appear when nobody in Design works remotely. Here is the relationship the query has to preserve.811

erDiagram
    DEPARTMENT ||--o{ EMPLOYEE : "employs"
    DEPARTMENT {
        int id PK
        string name
    }
    EMPLOYEE {
        int id PK
        int department_id FK
        boolean remote
        int salary
    }

A department has zero or more employees. Each employee belongs to one department through a foreign key: employee.department_id refers to the primary key department.id. Department 1 is Engineering and department 2 is Design. remote records whether the employee works remotely, and salary is monthly pay in yuan.

Employee iddepartment_idremotesalary
111true8,000
121false12,000
212false16,000

Engineering should have employee 11. Design should have an empty employee list. In SQL, I start from departments, use a left outer join and put the filter on employees in the ON clause.

SELECT d.name, e.id AS employee_id
FROM department AS d
LEFT JOIN employee AS e
  ON e.department_id = d.id AND e.remote = TRUE;

SQL returns (Engineering, 11) and (Design, NULL). In Prisma Client I can ask for a nested result. The where inside employees filters the list attached to each department.8

const departments = await prisma.department.findMany({
  select: {
    name: true,
    employees: { where: { remote: true }, select: { id: true } },
  },
});

In Drizzle 0.44.2 I first declare the relationship with relations(...) and pass it alongside the table definitions in schema. I can then load the employees with with.4

const departments = await db.query.department.findMany({
  columns: { name: true },
  with: {
    employees: {
      columns: { id: true },
      where: (employee, { eq }) => eq(employee.remote, true),
    },
  },
});

Both nested reads return employees: [] for Design. To select only departments having remote employees, Prisma also accepts a filter on the outer query: where: { employees: { some: { remote: true } } }. A nested JavaScript result describes what comes back to the caller. It does not specify the SQL used to load those rows.8

⚠️ Warning: In Sequelize v6, adding where: { remote: true } to include: { association: 'employees', … } implicitly sets required: true. The resulting INNER JOIN drops Design entirely. To keep Design with an empty employees array, set required: false in that same include. Sequelize then generates a LEFT OUTER JOIN with the employee filter in ON.11

Can I use a correlated subquery to find employees above their department average?

With the same three employees, Engineering averages 10,000 yuan per month, so only employee 12 qualifies. Employee 21 is the sole member of Design and earns exactly its average. This time the result is a list of employee IDs. What I need to nest is the calculation.

SELECT e.id
FROM employee AS e
WHERE e.salary > (
  SELECT AVG(peer.salary)
  FROM employee AS peer
  WHERE peer.department_id = e.department_id
);

Both e and peer are aliases for employee. The inner SELECT refers to e.department_id from the outer query. That reference makes this a correlated subquery. Remove the department condition and the average becomes company-wide, incorrectly qualifying employee 21.

Prisma v6’s findMany.where cannot take an arbitrary subquery as the right operand of this comparison. I can run the SQL above with $queryRaw. In Drizzle, gt (“greater than”) can take the inner query object directly and produce a single statement.207273

import { avg, eq, gt } from 'drizzle-orm';
import { alias } from 'drizzle-orm/pg-core';

const peer = alias(employee, 'peer');
const departmentAverage = db.select({ value: avg(peer.salary) })
  .from(peer)
  .where(eq(peer.departmentId, employee.departmentId));

const aboveAverage = await db.select({ id: employee.id })
  .from(employee)
  .where(gt(employee.salary, departmentAverage));

I pass departmentAverage to gt without first calling await. Its reference to employee.departmentId only makes sense inside the outer statement.3

Sequelize 6.37.7 can express AVG with fn. Its public model API has no scalar subquery builder I can pass to Op.gt; findAll() returns a promise for results. The v6 subquery guide says, “you will still have to write that sub-query by yourself.” Here I use literal for the fixed inner SELECT and let findAll build the outer query. The example sets both the model name and the table name to lowercase employee so the outer reference resolves.10

const departmentAverage = literal(`(
  SELECT AVG(peer.salary) FROM employee AS peer
  WHERE peer.department_id = employee.department_id
)`);
const aboveAverage = await Employee.findAll({
  attributes: ['id'],
  where: { salary: { [Op.gt]: departmentAverage } },
});

I can also get the same answer entirely through the model API. I define a self-association named peers on the department ID, join each employee to everyone in their department (including themselves), group by the current employee’s ID and salary, and use having to compare that salary with AVG(peers.salary). With Sequelize 6.37.7 and SQLite, both versions returned only employee 12.10

For a department of 100 people, the self-join logically matches 10,000 employee pairs before grouping. The correlated version expresses the department average inside the comparison. If that is the query I intend to tune, I want to retain it. The target database’s execution plan and timings on representative data tell me how much work it actually does.

For this subquery, I prefer Drizzle. Both SELECT levels, the aggregate and the outer reference are visible in the builder. With the appropriate table definitions and alias helper for PostgreSQL, MySQL and SQLite, Drizzle 0.44.2 generated the correlated WHERE … > (SELECT AVG(…)) for all three. MySQL used backticks and the other two used double quotes for identifiers. This checks SQL generation. Running the query on the target database is a separate test.327

Can the schema and the query code be maintained separately?

The schema describes the structure of the data, including tables, columns and their relationships. Changing a filter usually affects one query. Recording an employee’s skills introduces a relationship. Where do I define it, and how does the query learn about it?

ORMWhere I describe the dataWhat the query depends on
PrismaModels and relations live in .prisma files. By 6.11 I could split them across files.Business code uses the client generated from the schema. After adding a relation field and regenerating the client, I can use it in select or include.528298
DrizzleTypeScript modules define tables and columns using a dialect-specific helper such as sqliteTable. In 0.44.2 I declare relationships for nested reads separately with relations(...).A query imports the tables it needs. TypeScript infers the result from the selected columns. An explicit join can supply its own condition. Loading by relation name with with needs the corresponding relation definition.1304
Sequelizesequelize.define or Model.init defines a model. Associations are declared between models.Callers import the model and use methods such as findAll. With TypeScript model classes, InferAttributes helps derive the types, but I still have to keep the class property declarations and the column definitions in Model.init aligned.931
TypeORMA typical entity class uses decorators such as @Column to mark persistent properties, plus relation decorators.Queries can live in a separate module and use an entity repository or query builder. For an application that already had SQL, learning the entity, repository and builder APIs was a significant extra cost for me.12

What did Prisma simplify about many-to-many relations?

A developer describing a seven-table application wrote of using Drizzle, “I was fighting all the time on the schema.” They found relations easier to change after moving to Prisma. The difference is easiest to see in the path from an employee to a skill.32

An employee can have many skills, and a skill can belong to many employees. Answering “Which skills does employee 11 have?” takes three tables.

TableKey fieldsExample rows
employeeid (primary key)Employees 11 and 12
skillid (primary key), name(1, 'SQL'), (2, 'TypeScript')
Employee–skill junction tableemployee_id and skill_id are foreign keys. The pair is unique.(11, 1), (11, 2), (12, 1)

When I start from the models and the junction table only needs those two IDs, Prisma supports an implicit many-to-many relation. I declare skills Skill[] on Employee and employees Employee[] on Skill. prisma migrate dev includes the SQL to create the junction table in the migration. prisma generate produces a client that recognizes skills, so a caller can select the names directly.3334

const person = await prisma.employee.findUniqueOrThrow({
  where: { id: 11 },
  select: { skills: { select: { name: true } } },
});
// person.skills contains { name: 'SQL' } and { name: 'TypeScript' }

Drizzle 0.44.2 needs an explicit employeeSkill table and two foreign keys. Drizzle Kit uses those table definitions to generate the migration. The separate relations(...) declarations tell the relational query API how to traverse the links. On the employee side I declare skillLinks: many(employeeSkill). On the junction table I describe both ends.435

const employeeSkillRelations = relations(employeeSkill, ({ one }) => ({
  employee: one(employee, { fields: [employeeSkill.employeeId], references: [employee.id] }),
  skill: one(skill, { fields: [employeeSkill.skillId], references: [skill.id] }),
}));

Once those definitions are registered, the nested read follows the same path.

const person = await db.query.employee.findFirst({
  where: (employee, { eq }) => eq(employee.id, 11),
  columns: { id: true },
  with: {
    skillLinks: { columns: {}, with: { skill: { columns: { name: true } } } },
  },
});
// Each link has the shape { skill: { name: 'SQL' } }.
const skills = person.skillLinks.map(link => link.skill);

Prisma exposes person.skills directly. With Drizzle’s relational query API at the time, I read person.skillLinks and take the skill from each link. I could also use its SQL query builder to join the junction table and select just the skill names. If I need to record when each employee earned a certification, that date belongs to the relationship itself. Prisma then needs an explicit junction model too.433

How do I write a migration to add a date column to 10,000 existing notices?

Suppose notice contains 10,000 rows. I want to add a nullable revised_date and leave it null for existing notices. Updating the model lets the application recognize the field. A migration records the database change in a file so each environment can apply the steps in order.

ToolHow the migration is producedWhat I review
Drizzle Kitdrizzle-kit generate compares the table definitions with the previous schema snapshot and generates .sql for the configured dialect. drizzle-kit migrate applies it.Does the SQL add a nullable date column to the existing table?35
Prisma MigrateIn development, prisma migrate dev generates and applies migration.sql. --create-only lets me inspect and edit it first. prisma migrate deploy applies pending migrations at deployment.If old rows need a value computed from existing columns, I can add that backfill to the SQL before deployment.34
Sequelize CLImigration:generate creates a JavaScript file. I write queryInterface.addColumn in up and the reverse operation in down. Both can also execute handwritten SQL.Which SQL does the target dialect generate? Dropping the new column in down restores the old structure but also discards dates recorded since the upgrade.3637
TypeORMmigration:generate compares entity definitions with the connected database. By default it generates TypeScript with up and down; JavaScript output is also available. Generated migrations commonly use queryRunner.query(...). I can use queryRunner.addColumn(...) in a handwritten migration. migration:run applies it.Verify the database used for the comparison and inspect the generated SQL. If someone already added the column manually in development, the starting schema differs.38

Sequelize can choose the dialect when the migration runs. On an in-memory SQLite database with Sequelize 6.37.7, queryInterface.addColumn('notice', 'revised_date', { type: DataTypes.DATEONLY, allowNull: true }) logged the statement below. Other dialects can compile that same API call using their own syntax. Backticks I put in a SQL string myself stay in the string.37

ALTER TABLE `notice` ADD `revised_date` DATE;

Prisma Migrate ties migration history to a database provider, and Drizzle Kit generates SQL for a configured dialect. If I develop on SQLite and deploy on PostgreSQL, I test the production upgrade by loading the old schema and representative data into the target PostgreSQL version and replaying the migrations there.3935

Who manages the connection pool, and what makes a request wait?

I was moving records out of a JSON file. A SQLite database was still a single file I could copy. In Cursor I asked, “can nodejs handle concurrent writes from different processes connections to single sqlitedb file”. My next question was “what abour sequlise or drizzle orm does they support safe handling of such ccase ?”

Why can several processes open SQLite but only one write at a time?

SQLite’s isolation documentation puts it precisely: “There can only be a single writer at a time to an SQLite database.” More than one process can have a connection open. Writers to the same database take turns regardless of whether I use Sequelize or Drizzle.4041

I tried two processes in write-ahead logging (WAL) mode, which records changes in a separate log before checkpointing them back into the database file. Process A started a write transaction and held it open. B could still read the last committed data. With its busy timeout set to zero, B immediately received SQLITE_BUSY when it tried BEGIN IMMEDIATE to start its own write transaction. Once A committed, B could write. B already had a connection throughout this test. What it needed was the write lock.4042

With PostgreSQL, do I configure the pool in the ORM or in the driver?

My next practical question was “what is default pool setting for sequelize”. Suppose three requests reach a service and each needs a PostgreSQL connection. A connection pool lends a connection to a request and takes it back for reuse. With a maximum of two, the third request waits while both connections are checked out. If the configured acquisition timeout expires, the request fails. The maximum is a ceiling. The driver, configuration and load determine how many connections are actually open.43

July 2025 candidateWho owns the PostgreSQL pool?How I limit a pool to two connections or supply a different client
Sequelize 6.37.7Sequelize manages checkout and release through sequelize-pool. The PostgreSQL driver opens the connections.Set pool: { max: 2 } in the Sequelize constructor. The defaults in this version were max: 5, min: 0 and a 60-second acquisition timeout (acquire). The guide’s 30 seconds is an example setting. The constructor exposes pool settings without a general-purpose external pool instance option.4445
Drizzle 0.44.2The drizzle-orm/node-postgres adapter uses pg.Pool. It can accept an existing pool or create one from connection settings.I can create new Pool({ connectionString, max: 2 }) and pass it to drizzle({ client: pool }). To use postgres.js with the same database, I use its client and the matching Drizzle adapter.46
Prisma 6.11By default, Prisma’s query engine manages the pool for relational databases. Driver adapters were a preview option in this version.On the default path, set connection_limit=2 in the connection URL. pool_timeout limits the queue wait. With the PostgreSQL driver adapter, the underlying pg driver supplies the pool settings.475
TypeORM 0.3.24Its PostgreSQL driver loads pg by default and constructs the driver’s Pool.Set poolSize: 2 in the DataSource options. TypeORM passes max: 2 to the driver. extra carries driver-specific options. A replacement module supplied through driver has to implement the expected driver interface.48

In the same session I wrote, “i want a separate process management script to start 3 production processes how”. With one Sequelize instance and one pool capped at two per process, three processes can hold up to six pooled PostgreSQL connections between them.44

In Java I was used to accessing HikariCP through a DataSource. In Node.js, Sequelize gave me the most convenient place to set the limit and acquisition timeout. Drizzle gave me the flexibility I wanted when the application already owned a pg.Pool.494645

📓 Note: As node-postgres puts it, “You must use the same client instance for all statements within a transaction.” Drizzle 0.44.2’s node-postgres adapter uses instanceof Pool to recognize a pool. A custom object with query() and connect() alone will not select that branch. One option is to check out a client, pass it to drizzle({ client }) and release it after commit or rollback.50

Which query would I use to choose an ORM?

For the project itself, my requirement was modest. In my original words, “for testing i will only use one process and sqlite and in production i will change to mysql or pgsql”. A notice arriving a second time with the same ID should update its existing row. With the ID as the primary key, the same Sequelize model served local SQLite and the prospective MySQL configuration. The business operation was a single upsert(record).

For a reporting application I would take the department-average query and change one requirement: exclude probationary employees when computing the average. With Drizzle I change the inner query object. With Sequelize v6 I change the predicate inside literal if I want to retain the subquery. With Prisma I can keep the whole parameterized statement. The query my team expects to change most often is the one I would take into an ORM evaluation.3107

Footnotes

  1. Drizzle Team. (2025, June 4). Drizzle ORM 0.44.2 [Source code]. GitHub. Dialect options in this release, SQLite table definitions. AlexBlokh. (2023, May 16). MSSQL dialect [Issue #585]. GitHub. SQL Server dialect request. ↩ ↩2 ↩3

  2. ikdi. (2023, March 19). Add support for Oracle DB [Discussion #2442]. GitHub. Drizzle Oracle support request. kanso-git. (2020, June 25). Support Oracle DB [Issue #2853]. GitHub. Prisma Oracle support request. ↩ ↩2 ↩3

  3. Drizzle Team. (2025, June 4). SQL functions and conditional operators (v0.44.2). GitHub. Exported function helpers, Built-in avg, Comparison operands and exists subquery examples. ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7

  4. Drizzle Team. (n.d.). Relational Queries v1 to v2. Drizzle ORM Documentation. Junction tables and nested reads in relational queries v1. Drizzle Team. (2025, June 4). Relations (v0.44.2). GitHub. Relation definitions and query options in 0.44.2. ↩ ↩2 ↩3 ↩4 ↩5

  5. Prisma. (2025, July 1). Prisma ORM 6.11.0 [Release]. GitHub. Release notes, Connectors in the corresponding engine release. Prisma. (n.d.). Supported databases. Prisma ORM v6 Documentation. Supported databases and versions. ↩ ↩2 ↩3

  6. Prisma. (n.d.). Aggregation, grouping, and summarizing. Prisma ORM v6 Documentation. Aggregations and _avg. ↩

  7. Prisma. (n.d.). Filtering and sorting and Raw queries. Prisma ORM v6 Documentation. Combining filters, Executing parameterized SQL. ↩ ↩2 ↩3 ↩4 ↩5

  8. Prisma. (n.d.). Relation queries, “Nested reads”. Prisma ORM v6 Documentation. Nested reads. Sequelize. (n.d.). Eager loading, “Fetching all associated elements”. Sequelize v6 Documentation. Fetching associated elements. ↩ ↩2 ↩3 ↩4 ↩5

  9. Sequelize contributors. (2025, March 28). Sequelize v6.37.7 [Source code]. GitHub. Dialect selection. Sequelize. (n.d.). Model basics. Sequelize v6 Documentation. Two ways to define a model. ↩ ↩2 ↩3

  10. Sequelize. (n.d.). Model querying – Basics and Sub queries. Sequelize v6 Documentation. Functions and columns in a predicate, Sub Queries, paragraph introducing sequelize.literal. ↩ ↩2 ↩3 ↩4 ↩5 ↩6

  11. Sequelize. (n.d.). Eager loading, “Eager loading filtered at the associated model level”. Sequelize v6 Documentation. Filters on eager-loaded associations and generated joins. The department example was checked with Sequelize 6.37.7 and in-memory SQLite. ↩ ↩2 ↩3

  12. TypeORM contributors. (2025, May 14). TypeORM 0.3.24 [Source code and documentation]. GitHub. Drivers, query builders and entity repositories, Using parameters in query conditions. ↩ ↩2 ↩3

  13. TypeORM contributors. (2025, May 14). Repository and Select using QueryBuilder (v0.3.24). GitHub. Single-column average, Using subqueries, Adding a condition to a left join. ↩ ↩2

  14. Bhattacharya, N. (2022, October 21). Node.js Sequelize with Oracle Database — it’s official [Guest post published by C. Jones]. Oracle Developers, Medium. Initial Sequelize version and Oracle versions tested. TypeORM contributors. (2022, March 4). TypeORM 0.2.45. GitHub. Driver installation instructions. ↩

  15. lroal. (2025, May 8). You should really try out Orange ORM [Comment and supported databases table]. Reddit. Author’s introduction and database support table. ↩

  16. Orange ORM contributors. (2025, July 3). Orange ORM (commit e15d16b) [Source code]. GitHub. Order filter example, How any invokes the callback, Building the EXISTS predicate. ↩

  17. IamFr0ssT. (2024, October 31). I use typeorm, but the support is not good for older versions of mssql [Comment, para. 1]. Reddit. Experience with older SQL Server versions. TypeORM contributors. (2025, May 14). SelectQueryBuilder (v0.3.24). GitHub. SQL Server pagination branch. Microsoft. (n.d.). SELECT – ORDER BY clause (Transact-SQL). Microsoft Learn. SQL Server versions supporting OFFSET and FETCH. ↩

  18. Sequelize. (n.d.). Model querying – Basics, “Operators”. Sequelize v6 Documentation. PostgreSQL-specific iLike. ↩

  19. devklick. (2022, May 13). Mimic COALESCE behaviour using groups of conditions when querying with Prisma client [Question]. Stack Overflow. Original question, paragraphs 1–2 and SQL expression. For comparison, see Kysely’s first non-null argument and Knex identifier and value bindings. ↩

  20. Prisma. (2025, May 16). Prisma Client generated types (v6.8.2) [Test snapshot]. GitHub. Generated WhereInput, Date comparison filters and argument types. Prisma. (2025, July 1). Prisma Client generated types (v6.11.0) [Test snapshot]. GitHub. July release date filters. Prisma. (n.d.). Prisma Client API, “Compare columns in the same table”. Prisma ORM v6 Documentation. Restrictions on field references. ↩ ↩2 ↩3

  21. Prisma. (n.d.). TypedSQL. Prisma ORM v6 Documentation. Writing SQL files and generating types. ↩

  22. Drizzle Team. (2025, June 4). PostgreSQL select query builder (v0.44.2), where examples. GitHub. SQL templates in conditions. ↩

  23. Drizzle Team. (n.d.). Magic sql operator, “Convert sql to string and params”. Drizzle ORM Documentation. SQL and parameters for three dialects. ↩ ↩2 ↩3

  24. PostgreSQL Global Development Group. (n.d.). Date/time types, § 8.5.1. PostgreSQL 17 Documentation. Date input and literals. SQLite. (n.d.). Datatypes in SQLite, § 2.2. SQLite Documentation. Date and time storage classes. ↩

  25. Sequelize. (n.d.). Raw queries. Sequelize v6 Documentation. Bind parameters. ↩

  26. Knex contributors. (n.d.). FunctionHelper (v3.1.0) [Source code]. GitHub. Built-in function helpers. Knex contributors. (n.d.). Raw parameter binding. Knex.js. Binding identifiers and values in raw SQL. ↩

  27. Drizzle Team. (n.d.). SQL select and Filter and conditional operators. Drizzle ORM Documentation. Selecting from a subquery, Subqueries in filter operators. ↩ ↩2

  28. Prisma. (2025, April 29). Prisma ORM 6.7.0. GitHub. Multi-file Prisma schemas are now production-ready. ↩

  29. In 2023, kizomanizo liked being able to split Sequelize models by table and qualified their Prisma comparison with “the last time I checked”. By July 2025, multi-file schemas had been generally available since Prisma 6.7 in April. kizomanizo. (2023, October 10). Sequelize has a cli which will help you to get the app built in a few minutes [Comment, para. 1]. Reddit. Comment on splitting models by table. ↩

  30. Drizzle Team. (n.d.). SQL select, “Partial select”. Drizzle ORM Documentation. Inferring the result type of a partial select. ↩

  31. Sequelize. (n.d.). TypeScript, “Usage”. Sequelize v6 Documentation. Model class declarations, type inference and Model.init. ↩

  32. sendcodenotnudes. (2025, April 22). I needed an ORM for an application with a relatively simple database [Comment, paras. 1–4]. Reddit. Modeling the seven-table application. ↩

  33. Prisma. (n.d.). Many-to-many relations. Prisma ORM v6 Documentation. Implicit and explicit many-to-many relations. ↩ ↩2

  34. Prisma. (n.d.). Development and production. Prisma ORM v6 Documentation. Developing, customizing and deploying migrations. ↩ ↩2

  35. Drizzle Team. (n.d.). Drizzle Kit generate and Drizzle Kit migrate. Drizzle Documentation. Comparing snapshots and generating SQL, Applying migrations. ↩ ↩2 ↩3

  36. Sequelize. (n.d.). Migrations. Sequelize v6 Documentation. Generating, writing and reverting migrations. ↩

  37. Sequelize. (n.d.). Query interface, “Adding a column to a table”. Sequelize v6 Documentation. Adding a column and the generated SQLite statement. ↩ ↩2

  38. TypeORM contributors. (2025, May 14). Migrations (v0.3.24). GitHub. Generating migrations from schema differences. ↩

  39. Prisma. (n.d.). Limitations and known issues, “You cannot automatically switch database providers”. Prisma ORM v6 Documentation. Switching providers and migration history. ↩

  40. SQLite. (n.d.). Isolation in SQLite. SQLite Documentation. Isolation Between Database Connections, paragraph on serializing writes. ↩ ↩2

  41. Sequelize contributors. (2025, March 28). SQLite connection manager (v6.37.7). GitHub. SQLite connection acquisition and release. ↩

  42. SQLite. (n.d.). Result and error codes, “SQLITE_BUSY”. SQLite Documentation. Competing write transactions. The two-process experiment was run during editorial verification. ↩

  43. node-postgres contributors. (n.d.). Pool API. node-postgres. Pool checkout, release and queuing. ↩

  44. Sequelize. (n.d.). Connection pool, final paragraph. Sequelize v6 Documentation. Allocating the connection budget across processes. ↩ ↩2

  45. Sequelize contributors. (2025, March 28). Abstract connection manager (v6.37.7). GitHub. Pool implementation, initialization and defaults. ↩ ↩2

  46. Drizzle Team. (2025, June 4). Node-postgres driver (v0.44.2). GitHub. Accepting a client or constructing a pool. Drizzle Team. (n.d.). PostgreSQL. Drizzle ORM Documentation. node-postgres and postgres.js adapters. ↩ ↩2

  47. Prisma. (n.d.). Connection pool. Prisma ORM v6 Documentation. Query engine, pool size and waiting queue. Prisma. (2025, July 1). Prisma ORM 6.11.0. GitHub. Driver adapters and preview features in this release. ↩

  48. TypeORM contributors. (2025, May 14). PostgresDriver (v0.3.24). GitHub. Loading the driver, merging options and creating the pool. ↩

  49. Wooldridge, B., & HikariCP contributors. (n.d.). HikariCP. GitHub. Initializing a HikariDataSource. ↩

  50. Drizzle Team. (2025, June 4). Node-postgres session (v0.44.2). GitHub. Accepted client types, Pool detection and transaction checkout/release. node-postgres contributors. (n.d.). Transactions. node-postgres. Transactions, first paragraph. ↩

© 2025 borui. All rights reserved. This content may be freely reproduced, displayed, modified, or distributed with proper attribution to borui and a link to the article: borui (2025-07-08). Choosing a Node.js ORM: which queries survive a change of database?. https://caiborui.com/blog/2025-07-08-en-nodejs-orm-database-support-queries-migrations

@misc{borui2025-f60f97ec,
  author = {borui},
  title = {{Choosing a Node.js ORM: which queries survive a change of database?}},
  year = {2025},
  publisher = {borui's blog},
  url = {https://caiborui.com/blog/2025-07-08-en-nodejs-orm-database-support-queries-migrations}
}