Use this file to discover Exa products, pricing, evaluations, comparisons, use cases, agent interfaces, and technical documentation before exploring further.
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.
Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.
Libraries and code examples
Drizzle ORM
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.
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;
}
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
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.
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.
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.
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.
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'))
})
}
MikroORM
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.
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.
_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,
};
}
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.