# JavaScript ORM libraries

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

| Library | Monthly downloads | Stars | Last release | License |
| --- | --- | --- | --- | --- |
| [Drizzle ORM](#drizzle-orm) | 182.3M | 36.3K | Oct 2026 | Apache-2.0 |
| [Prisma Client](#prisma) | 95.8M | 47.7K | Oct 2026 | Apache-2.0 |
| [Mongoose](#mongoose) | 35.2M | 27.4K | Nov 2026 | MIT |
| [TypeORM](#typeorm) | 26.9M | 36.7K | Nov 2026 | MIT |
| [Sequelize](#sequelize) | 15.8M | 30.3K | Mar 2026 | MIT |
| [MikroORM](#mikroorm) | 5.8M | 9.3K | Nov 2026 | MIT |
| [Objection.js](#objection) | 1.2M | 17 | Nov 2026 | MIT |

Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

[Drizzle ORM](#drizzle-orm) has the most monthly downloads in this comparison, at 182.3M.

## Capabilities

| Library | SQL model mapping | MongoDB model mapping |
| --- | --- | --- |
| [Drizzle ORM](#drizzle-orm) | Yes | No |
| [Prisma Client](#prisma) | Yes | No |
| [Mongoose](#mongoose) | No | Yes |
| [TypeORM](#typeorm) | Yes | Yes |
| [Sequelize](#sequelize) | Yes | No |
| [MikroORM](#mikroorm) | Via plugin | Via plugin |
| [Objection.js](#objection) | Yes | No |

## Libraries

### Drizzle ORM

[GitHub](https://github.com/drizzle-team/drizzle-orm) · [npm](https://www.npmjs.com/package/drizzle-orm) · [Docs](https://orm.drizzle.team/docs/overview)

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
- Capabilities: [From the Drizzle ORM docs](https://orm.drizzle.team/docs/overview)

**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.

**Watch out for**

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

```sh
npm install drizzle-orm@0.45.4 better-sqlite3
```

**better-auth/better-auth** (30.8K stars)

[better-auth/better-auth](https://github.com/better-auth/better-auth) 

```javascript
async count({ model, modelKey = model, where }) {
					const table = getSchema(model);
					const clause = where
						? convertWhereClause(where, model, modelKey)
						: [];
					const res = await db
						.select({ count: count() })
						.from(table)
						.where(...clause);
					return res[0].count;
				}

```

[packages/drizzle-adapter/src/drizzle-adapter.ts](https://github.com/better-auth/better-auth/blob/2a11b2687640211b38ba999fdf791e24af5775a0/packages/drizzle-adapter/src/drizzle-adapter.ts#L1029) · [More projects using Drizzle ORM →](https://dashboard.exa.ai/playground/search?q=drizzle-orm%20GitHub%20projects)

**Quickstart**

```javascript
import { drizzle } from "drizzle-orm/better-sqlite3";
const db = drizzle(":memory:");
console.log(db.all("select 1 as value"));
db.$client.close();

```

From [get-started-sqlite](https://orm.drizzle.team/docs/get-started-sqlite)

### Prisma Client

[GitHub](https://github.com/prisma/orm) · [npm](https://www.npmjs.com/package/@prisma/client) · [Docs](https://www.prisma.io/docs/orm/v7/prisma-client)

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
- Capabilities: [From the Prisma Client docs](https://www.prisma.io/docs/orm/v7/prisma-client)

**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.

**Watch out for**

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

```sh
npm install @prisma/client@7.10.1 @prisma/adapter-better-sqlite3@7.10.1 prisma@7.10.1 typescript tsx @types/node
```

**calcom/cal.diy** (50.1K stars)

[calcom/cal.diy](https://github.com/calcom/cal.diy) 

```typescript
async function changeSMSLockState(identifier: string, status: SMSLockState) {
  let userId: number | undefined, teamId: number | undefined;

  if (identifier.startsWith("sms:user:")) {
    userId = Number(identifier.slice(9));
  } else if (identifier.startsWith("sms:team:")) {
    teamId = Number(identifier.slice(9));
  }

  if (userId) {
    const user = await prisma.user.findUnique({ where: { id: userId, profiles: { none: {} } } });
    if (user?.smsLockReviewedByAdmin) return;

    await prisma.user.update({
      where: {
        id: userId,
        profiles: { none: {} },
      },
      data: {
        smsLockState: status,
      },
    });
  } else {
    const team = await prisma.team.findUnique({
      where: { id: teamId, parentId: null, isOrganization: false },
    });
    if (team?.smsLockReviewedByAdmin) return;

    await prisma.team.update({
      where: {
        id: teamId,
        parentId: null,
        isOrganization: false,
      },
      data: {
        smsLockState: status,
      },
    });
  }
}

```

[packages/lib/smsLockState.ts](https://github.com/calcom/cal.diy/blob/ae027bb70e694e2d2c44569f398d6cbcee0389b1/packages/lib/smsLockState.ts#L25) · [More projects using Prisma Client →](https://dashboard.exa.ai/playground/search?q=JavaScript%20TypeScript%20application%20%40prisma/client%20models%20entity%20relations%20persistence%20migrations%20database%20ORM&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```typescript
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

```

From [README.md](https://www.prisma.io/docs/getting-started/prisma-orm/quickstart/sqlite)

### Mongoose

[GitHub](https://github.com/Automattic/mongoose) · [npm](https://www.npmjs.com/package/mongoose) · [Docs](https://mongoosejs.com/docs/index.html)

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
- Capabilities: [From the Mongoose docs](https://mongoosejs.com/docs/index.html)

**Strengths**

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

**Watch out for**

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

```sh
npm install mongoose@9.12.2
```

**novuhq/novu** (40.4K stars)

[novuhq/novu](https://github.com/novuhq/novu) 

```javascript
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);
  }

```

[libs/dal/src/repositories/base-repository.ts](https://github.com/novuhq/novu/blob/fd9c697630696b96249b8d1eb57de402c3bf3bb0/libs/dal/src/repositories/base-repository.ts#L222) · [More projects using Mongoose →](https://dashboard.exa.ai/playground/search?q=mongoose%20GitHub%20projects)

**Quickstart**

```javascript
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);

```

From [index.html](https://mongoosejs.com/docs/index.html)

### TypeORM

[GitHub](https://github.com/typeorm/typeorm) · [npm](https://www.npmjs.com/package/typeorm) · [Docs](https://typeorm.io/docs/entity/separating-entity-definition/)

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
- Capabilities: [From the TypeORM docs](https://typeorm.io/docs/entity/separating-entity-definition/)

**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.

**Watch out for**

- **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.

```sh
npm install typeorm@1.1.3 sqlite3
```

**MichalLytek/type-graphql** (8.1K stars)

[MichalLytek/type-graphql](https://github.com/MichalLytek/type-graphql) 

```typescript
export async function seedDatabase() {
  const recipeRepository = dataSource.getRepository(Recipe);
  const ratingRepository = dataSource.getRepository(Rating);
  const userRepository = dataSource.getRepository(User);

  const defaultUser = userRepository.create({
    email: "admin@github.com",
    nickname: "administrator",
    password: "s3cr3tp4ssw0rd",
  });
  await userRepository.save(defaultUser);

  const recipes = recipeRepository.create([
    {
      title: "Recipe 1",
      description: "Desc 1",
      author: defaultUser,
      ratings: ratingRepository.create([
        { value: 2, user: defaultUser },
        { value: 4, user: defaultUser },
        { value: 5, user: defaultUser },
        { value: 3, user: defaultUser },
        { value: 4, user: defaultUser },
      ]),
    },
    {
      title: "Recipe 2",
      author: defaultUser,
      ratings: ratingRepository.create([
        { value: 2, user: defaultUser },
        { value: 4, user: defaultUser },
      ]),
    },
  ]);
  await recipeRepository.save(recipes);

  return {
    defaultUser,
  };
}

```

[examples/typeorm-basic-usage/helpers.ts](https://github.com/MichalLytek/type-graphql/blob/77a79f2e13a39185a8669087497dcf626bb2f285/examples/typeorm-basic-usage/helpers.ts#L4) · [More projects using TypeORM →](https://dashboard.exa.ai/playground/search?q=JavaScript%20TypeScript%20application%20typeorm%20models%20entity%20relations%20persistence%20migrations%20database%20ORM&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```typescript
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();

```

From [getting-started.md](https://typeorm.io/docs/entity/separating-entity-definition/)

### Sequelize

[GitHub](https://github.com/sequelize/sequelize) · [npm](https://www.npmjs.com/package/sequelize) · [Docs](https://sequelize.org/docs/v6/getting-started/)

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
- Capabilities: [From the Sequelize docs](https://sequelize.org/docs/v6/getting-started/)

**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.

**Watch out for**

- **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.

```sh
npm install sequelize@6.37.8 sqlite3
```

**hedgedoc/hedgedoc** (7.5K stars)

[hedgedoc/hedgedoc](https://github.com/hedgedoc/hedgedoc) 

```typescript
async function updatePasswordHashHook (user, options) {
    // suggested way to hash passwords to be able to do this asynchronously:
    // @see https://github.com/sequelize/sequelize/issues/1821#issuecomment-44265819

    if (!user.changed('password')) {
      return Promise.resolve()
    }

    return Scrypt.kdf(user.getDataValue('password'), { logN: 15 }).then(keyBuf => {
      user.setDataValue('password', Buffer.from(keyBuf).toString('hex'))
    })
  }

```

[lib/models/user.js](https://github.com/hedgedoc/hedgedoc/blob/dbb71bae523af1dfba30006e4922143d8004f741/lib/models/user.js#L194) · [More projects using Sequelize →](https://dashboard.exa.ai/playground/search?q=JavaScript%20TypeScript%20application%20sequelize%20models%20entity%20relations%20persistence%20migrations%20database%20ORM&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```typescript
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);

```

From [model-basics.md](https://sequelize.org/docs/v6/getting-started/)

### MikroORM

[GitHub](https://github.com/mikro-orm/mikro-orm) · [npm](https://www.npmjs.com/package/@mikro-orm/core) · [Docs](https://mikro-orm.io/docs/quick-start)

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
- Capabilities: [From the MikroORM docs](https://mikro-orm.io/docs/quick-start)

**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.

**Watch out for**

- **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.

```sh
npm install @mikro-orm/core@7.2.10 @mikro-orm/sqlite@7.2.10
```

**mikro-orm/nestjs-realworld-example-app** (344 stars)

[mikro-orm/nestjs-realworld-example-app](https://github.com/mikro-orm/nestjs-realworld-example-app) 

```typescript
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);
  }

```

[src/user/user.service.ts](https://github.com/mikro-orm/nestjs-realworld-example-app/blob/3bb628edebc95da30adcbeeb2ecb33158c3dbc95/src/user/user.service.ts#L76) · [More projects using MikroORM →](https://dashboard.exa.ai/playground/search?q=JavaScript%20TypeScript%20application%20%40mikro-orm/core%20models%20entity%20relations%20persistence%20migrations%20database%20ORM&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```typescript
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);

```

From [README.md](https://mikro-orm.io/docs/quick-start)

### Objection.js

[GitHub](https://github.com/ditojs/objection) · [npm](https://www.npmjs.com/package/objection) · [Docs](https://raw.githubusercontent.com/ditojs/objection/main/README.md)

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
- Capabilities: [From the Objection.js docs](https://raw.githubusercontent.com/ditojs/objection/main/README.md)

**Strengths**

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

**Watch out for**

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

```sh
npm install objection@4.4.3 knex sqlite3
```

**Vincit/objection-graphql** (302 stars)

[Vincit/objection-graphql](https://github.com/Vincit/objection-graphql) 

```javascript
_buildEagerSegment(astNode, modelClass, astRoot) {
    const filters = {};
    const relations = modelClass.getRelations();
    let expression = '';

    for (let i = 0, l = astNode.selectionSet.selections.length; i < l; i += 1) {
      const selectionNode = astNode.selectionSet.selections[i];
      const relation = relations[selectionNode.name.value];

      if (relation) {
        expression = this._buildEagerRelationSegment(selectionNode, relation, expression, filters, astRoot);
      } else if (selectionNode.kind === KIND_FRAGMENT_SPREAD) {
        expression = this._buildEagerFragmentSegment(selectionNode, modelClass, expression, filters, astRoot);
      }
    }

    return {
      expression,
      filters,
    };
  }

```

[lib/SchemaBuilder.js](https://github.com/Vincit/objection-graphql/blob/70a8359852a765828af7f7099461068ced5e468d/lib/SchemaBuilder.js#L311) · [More projects using Objection.js →](https://dashboard.exa.ai/playground/search?q=objection%20GitHub%20projects)

**Quickstart**

```javascript
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();

```

From [getting-started.html](https://ditojs.github.io/objection/guide/getting-started.html)

## FAQ

### Which JavaScript ORM should I use?

On a SQL database with TypeScript, most projects choose between [Prisma](#prisma) and [Drizzle ORM](#drizzle-orm). Prisma generates a client from a schema file, while Drizzle keeps the schema and queries in TypeScript. [TypeORM](#typeorm) and [MikroORM](#mikroorm) organize code around entity classes, a pattern taken from Hibernate and Doctrine. For MongoDB, use [Mongoose](#mongoose).

### Drizzle vs Prisma: which should I use?

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 vs Prisma: which should I use?

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.

### Sequelize vs TypeORM: which should I use?

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.

### What is the difference between an ORM and a query builder?

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](#objection) sits between the two: it is built on knex and adds models and relations while keeping SQL as the query language.

## How this page was built

Data checked Nov 19, 2026.

Reproduce it with the Exa API:

```json
{
  "endpoint": "/search",
  "body": {
    "query": "Best JavaScript ORM libraries Prisma TypeORM Sequelize MikroORM code examples",
    "numResults": 5
  }
}
```

Docs: https://exa.ai/docs/reference/search
