JavaScript ORM libraries

Updated Nov 2026

JavaScript ORM (object-relational mapping) libraries map database tables to objects and turn method calls into SQL. These libraries let developers query a database through objects instead of SQL strings, with TypeScript types that catch a misspelled column at compile time.

Popularity

Drizzle ORM has the most monthly downloads in this comparison, at 182.3M.

LibraryMonthly downloadsStarsLast releaseLicense
Drizzle ORM
182.3M
36.3KOct 2026Apache-2.0
Prisma Client
95.8M
47.7KOct 2026Apache-2.0
Mongoose
35.2M
27.4KNov 2026MIT
TypeORM
26.9M
36.7KNov 2026MIT
Sequelize
15.8M
30.3KMar 2026MIT
MikroORM
5.8M
9.3KNov 2026MIT
Objection.js
1.2M
17Nov 2026MIT
Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Libraries and code examples

Drizzle ORM declares database tables in TypeScript with functions such as pgTable and builds typed queries from them. The select API reads like SQL, with from, leftJoin, and where, while db.query fetches nested related records and still sends one SQL query. Drizzle supports PostgreSQL, MySQL, and SQLite, including serverless databases such as Neon, Turso, and Supabase. A companion command-line tool, Drizzle Kit, generates SQL migration files from the schema or pushes changes straight to the database.

Downloads / mo
182.3M
Stars
36.3K
Last release
0.45.4
License
Apache-2.0

Strengths

  • Relational and SQL-like queries. Writes joins with select and from, or reads nested records with db.query.
  • Runs in many runtimes. Works in Node.js, Bun, Deno, Cloudflare Workers, and browsers, with no dependencies.

Limitations

  • No MongoDB support. Supports PostgreSQL, MySQL, and SQLite databases, including serverless ones such as Neon and Turso.

Quickstart

From get-started-sqlite
$ npm install drizzle-orm@0.45.4 better-sqlite3
import { drizzle } from "drizzle-orm/better-sqlite3";
const db = drizzle(":memory:");
console.log(db.all("select 1 as value"));
db.$client.close();

Drizzle ORM examples

From open-source projects on GitHub

Prisma describes the database in a schema file, schema.prisma, and prisma generate turns its models into Prisma Client, a typed query library. Queries are method calls on that client, such as prisma.user.findMany, and nested writes create or update related records in one transaction. Prisma Migrate turns schema changes into SQL migration files. The next major version, a TypeScript rewrite of the ORM, is a release candidate, and the current version stays maintained on its own branch.

Downloads / mo
95.8M
Stars
47.7K
Last release
7.10.1
License
Apache-2.0

Strengths

  • Generates a model-specific client. Get query methods and types from the declared database models.
  • Rolls back failed nested writes. Create related records together with transactional guarantees.

Limitations

  • Requires client regeneration after changes. Run prisma generate after changing models or generator settings.
  • Migrate excludes MongoDB. Use db push for MongoDB schema changes.

Quickstart

From README.md
$ npm install @prisma/client@7.10.1 @prisma/adapter-better-sqlite3@7.10.1 prisma@7.10.1 typescript tsx @types/node
npm pkg set type=module
mkdir -p prisma
cat > prisma/schema.prisma <<'SCHEMA'
generator client {
  provider = "prisma-client"
  output = "../generated/prisma"
}
datasource db {
  provider = "sqlite"
}
model User {
  id Int @id @default(autoincrement())
  name String
}
SCHEMA
cat > prisma7.config.ts <<'CONFIG'
import { defineConfig } from "prisma/config";
import { resolve } from "node:path";
export default defineConfig({ schema: "prisma/schema.prisma", datasource: { url: "file:" + resolve("orm-demo.db") } });
CONFIG
npx prisma migrate dev --name init
npx prisma generate
cat > app.ts <<'APP'
import { PrismaClient } from "./generated/prisma/client";
import { PrismaBetterSqlite3 } from "@prisma/adapter-better-sqlite3";
import { resolve } from "node:path";
const prisma = new PrismaClient({ adapter: new PrismaBetterSqlite3({ url: "file:" + resolve("orm-demo.db") }) });
console.log(await prisma.user.create({ data: { name: "Ada" } }));
await prisma.$disconnect();
APP
npx tsx app.ts

Prisma Client examples

From open-source projects on GitHub

Mongoose models MongoDB documents in Node.js and, in alpha, Deno. Every model starts as a schema: new mongoose.Schema lists the fields and their types, and mongoose.model compiles the schema into a model. Models create, find, update, and delete documents, and each document is an instance of its model. The app opens the database with mongoose.connect and a MongoDB connection string.

Downloads / mo
35.2M
Stars
27.4K
Last release
9.12.2
License
MIT

Strengths

  • Schemas compiled into models. Defines document fields with mongoose.Schema, then compiles the schema into a model for queries.

Limitations

  • MongoDB only. Models MongoDB documents. SQL databases need one of the other libraries here.

Quickstart

From index.html
$ npm install mongoose@9.12.2
const mongoose = require("mongoose");
async function main() {
  await mongoose.connect("mongodb://127.0.0.1:27017/orm_demo");
  const Kitten = mongoose.model("Kitten", new mongoose.Schema({ name: String }));
  console.log(await Kitten.findOne({ name: "Silence" }));
  await mongoose.disconnect();
}
main().catch(console.error);

Mongoose examples

From open-source projects on GitHub
async findOneAndDelete(query: FilterQuery<T_DBModel> & T_Enforcement): Promise<T_MappedEntity | null> {
    const data = await this.MongooseModel.findOneAndDelete(query).lean();
    if (!data) return null;

    return this.mapEntity(data);
  }

TypeORM maps classes to tables with decorators such as @Entity and @Column, or with EntitySchema objects in plain JavaScript. Queries run through repositories, the Data Mapper pattern, or through methods on the entities themselves, the Active Record pattern. A DataSource holds the connection settings for one of many databases, including PostgreSQL, MySQL, SQLite, Microsoft SQL Server, Oracle, and MongoDB. The library also generates migrations, builds joins with its QueryBuilder, and runs in Node.js, browsers, React Native, and Electron.

Downloads / mo
26.9M
Stars
36.7K
Last release
1.1.3
License
MIT

Strengths

  • Offers two persistence styles. Use entity methods or repositories to organize database operations.
  • Loads mapped relations with records. Include related entities through find options.

Limitations

  • Schema synchronization risks production data. Use migrations instead of synchronize for production schema changes.
  • QueryBuilder disables eager loading. Add leftJoinAndSelect when a QueryBuilder query needs an eager relation.

Quickstart

From getting-started.md
$ npm install typeorm@1.1.3 sqlite3
import { DataSource, EntitySchema } from "typeorm";
const User = new EntitySchema({ name: "User", columns: { id: { type: Number, primary: true, generated: true }, name: { type: String } } });
const db = new DataSource({ type: "sqlite", database: ":memory:", entities: [User], synchronize: true });
await db.initialize();
console.log(await db.getRepository(User).save({ name: "Ada" }));
await db.destroy();

TypeORM examples

From open-source projects on GitHub

Sequelize is a promise-based ORM for PostgreSQL, MySQL, MariaDB, SQLite, Microsoft SQL Server, Snowflake, and Oracle Database. A model represents a table and is defined with sequelize.define or by extending the Model class. Associations such as hasOne and belongsTo add methods for reading and creating related records, which load eagerly or lazily. Transactions and read replication are built in. The maintainers are looking for help to finish the next major version, which is in alpha.

Downloads / mo
15.8M
Stars
30.3K
Last release
6.37.8
License
MIT

Strengths

  • Defines models with plain objects. Pass attribute definitions to sequelize.define to create a mapped model.
  • Adds methods for associated records. Use generated getters, setters, and creators on the association source.

Limitations

  • TypeScript models need explicit declarations. Declare model attributes by hand, since types aren't generated from a schema.
  • Reverse loading needs paired associations. Define the reverse association before including the source from its target.

Quickstart

From model-basics.md
$ npm install sequelize@6.37.8 sqlite3
const { Sequelize, DataTypes } = require("sequelize");
async function main() {
  const db = new Sequelize("sqlite::memory:", { logging: false });
  const User = db.define("User", { name: DataTypes.STRING });
  await db.sync();
  console.log((await User.create({ name: "Ada" })).toJSON());
  await db.close();
}
main().catch(console.error);

Sequelize examples

From open-source projects on GitHub

MikroORM is a TypeScript ORM built on three patterns from Doctrine and Hibernate: Data Mapper, Unit of Work, and Identity Map. Entities are defined with defineEntity, decorators, or EntitySchema. The entity manager, em, tracks every entity it loads or creates, and em.flush writes all changes in a single transaction. Each database has its own driver package, such as @mikro-orm/postgresql or @mikro-orm/mongodb, and RequestContext gives each web request its own identity map.

Downloads / mo
5.8M
Stars
9.3K
Last release
7.2.10
License
MIT

Strengths

  • Tracks changes across managed entities. Modify loaded objects and flush to write their changed fields.
  • Reuses one entity instance. Compare loaded records by object identity within a request.

Limitations

  • Requires a separate request context. Fork the entity manager for each concurrent request.
  • Collections need loading before access. getItems throws on a collection that isn't loaded, so populate the relation first.

Quickstart

From README.md
$ npm install @mikro-orm/core@7.2.10 @mikro-orm/sqlite@7.2.10
import { defineEntity, p } from "@mikro-orm/core";
import { MikroORM } from "@mikro-orm/sqlite";
const User = defineEntity({ name: "User", properties: { id: p.integer().primary(), name: p.string() } });
const orm = await MikroORM.init({ entities: [User], dbName: ":memory:" });
await orm.schema.create();
const em = orm.em.fork();
const user = em.create(User, { name: "Ada" });
em.persist(user);
await em.flush();
console.log(user);
await orm.close(true);

MikroORM examples

From open-source projects on GitHub
async update(id: number, dto: UpdateUserDto) {
    const user = await this.userRepository.findOneOrFail(id);
    this.em.assign(user, dto);
    await this.em.flush();

    return this.buildUserRO(user);
  }

Objection.js is a relational query builder built on knex, so it connects to every database knex supports. Models extend the Model class and declare their relations to other models. Queries use knex-style methods, eager loading fetches related records, and whole object graphs can be inserted or upserted at once. Schema changes stay outside the library, in knex migrations. Development continues at ditojs/objection under the same package name after the original repository changed hands.

Downloads / mo
1.2M
Stars
17
Last release
4.4.3
License
MIT

Strengths

  • Built on knex. Connects to every database knex supports, with SQLite, Postgres, and MySQL tested.

Limitations

  • No migrations from models. Schema changes go through knex migrations, not model definitions.

Quickstart

From getting-started.html
$ npm install objection@4.4.3 knex sqlite3
import { Model } from "objection";
import Knex from "knex";
const knex = Knex({ client: "sqlite3", connection: { filename: ":memory:" }, useNullAsDefault: true });
Model.knex(knex);
class Person extends Model { static get tableName() { return "persons"; } }
await knex.schema.createTable("persons", table => { table.increments("id"); table.string("firstName"); });
console.log(await Person.query().insert({ firstName: "Ada" }));
await knex.destroy();

Objection.js examples

From open-source projects on GitHub

FAQ

On a SQL database with TypeScript, most projects choose between Prisma and Drizzle ORM. Prisma generates a client from a schema file, while Drizzle keeps the schema and queries in TypeScript. TypeORM and MikroORM organize code around entity classes, a pattern taken from Hibernate and Doctrine. For MongoDB, use Mongoose.

Drizzle declares the schema in TypeScript, has no dependencies, and offers both SQL-like and relational query APIs. Prisma reads a separate schema file and needs prisma generate after each model change to rebuild its typed client. Both produce migrations, Drizzle through Drizzle Kit and Prisma through Prisma Migrate.

TypeORM maps decorated classes to tables and supports both the Active Record and Data Mapper patterns, so queries run through entity methods or repositories. Prisma has no entity classes. Its query methods are generated from the models in the schema file.

Both map tables to models and handle relations, transactions, and migrations. TypeORM declares entities with TypeScript decorators and also connects to MongoDB. Sequelize defines models with sequelize.define or by extending Model, and its TypeScript docs call for manual type declarations.

A query builder such as knex turns chained method calls into SQL. An ORM adds models, relations between them, and loading of related records. Objection.js sits between the two: it is built on knex and adds models and relations while keeping SQL as the query language.

For coding agents

Found your ORM library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official