Choose the abstraction and compatible dependency stack before comparing models, relations, drivers, and migrations.
A query builder expresses SQL operations. An ORM adds a model and relation vocabulary with its own loading and update semantics. The useful choice is how much of that model the library should own, and whether its database and toolchain dependencies fit the application.
| Package | Main model | Key setup concern |
|---|---|---|
| bookshelf | Models and collections over Knex | Its declared Knex compatibility range |
| knex | SQL query builder | Database client, dialect behavior, and pooling |
| orange-orm | Explicit table mapping and relation queries | Mapping and the selected database integration |
| sequelize | Models, associations, and ORM operations | Dialect driver and the package's model contract |
| typeorm | Entity metadata, repositories, and DataSource | Entity registration, driver, runtime, and initialization |
Bookshelf is built on an initialized Knex client and adds models, collections, relationships, and eager loading. That can be useful when maintaining an application already organized around its model conventions.
Its current publication declares a Knex peer range of >=0.15.0 and <0.22.0. The independently current Knex package does not satisfy that range. Do not combine the two latest package names and assume the resulting dependency graph is supported. The dependency range is an actual integration condition, not a reason by itself to label Bookshelf deprecated.
Knex itself provides query building, transactions, pooling, and schema operations for supported dialects. It does not automatically create a domain model or relation-loading policy. Choose it when explicit queries and application-owned modeling are preferable, and install the client needed for the database in use. Dialect-specific SQL behavior still matters despite a common JavaScript API.
Orange ORM maps database tables and columns and exposes relation-oriented queries such as getMany with a where expression and selected related data. It fits applications wanting a mapped query model with explicit control of the requested relation graph.
Database support varies by execution environment and driver. The package lists multiple optional database peers; that does not mean every driver should be installed or that no driver is needed for the chosen integration. Select the actual database path and use its supported mapping and runtime setup. A browser or HTTP integration should not be inferred from an ordinary direct database example.
Sequelize provides model definitions, associations, querying, and transactions through its own API. Database drivers are selected according to the dialect. Eager loading and transaction participation require deliberate query and application choices; defining an association is not a promise that every related record is loaded automatically.
Use the documentation for this exact sequelize package. Another package or development branch in the same project can have different imports and configuration. Switching to Sequelize changes model definitions, relation queries, lifecycle conventions, and migration tooling rather than just wrapping a Knex client.
TypeORM supports entity metadata and repository or Active Record styles. A DataSource is configured and initialized before obtaining repositories for the registered entities. Choose the database driver and the intended metadata approach rather than assuming one decorator example covers every JavaScript and TypeScript setup.
Its current Node engine range is ^20.19.0, ^22.13.0, or >=24.11.0. Database-specific optional peers apply to their integrations; they are not one universal requirement to install all listed databases. The chosen driver, build setup, and runtime must align.
Choose explicit SQL with Knex, existing Bookshelf conventions with a compatible stack, or the model vocabulary of Orange ORM, Sequelize, or TypeORM according to the application. Work through a representative relation query and transaction before deciding that a feature checklist establishes compatibility.
Migrate schema changes deliberately, preserve transaction boundaries, and inspect generated queries for the intended dialect and loading pattern. Replacing model syntax does not automatically migrate the database or preserve query behavior.
Choose entity metadata, repositories, and DataSource-based integration when that model fits, with the selected driver and supported runtime.
Choose explicit SQL query building, transactions, and schema operations when the application should own the higher-level domain model.
Choose its model, association, and transaction APIs with the appropriate dialect driver; use documentation matching the exact sequelize package.
Consider for an existing Knex-based model application, using the older Knex peer range it actually declares rather than an independent latest Knex install.
Choose its explicit table mapping and relation-oriented query model when that API fits the required database and driver integration.
TypeORM is an ORM that can run in Node.js, Browser, Cordova, Ionic, React Native, NativeScript, Expo, and Electron platforms and can be used with TypeScript and JavaScript (ES2023). Its goal is to always support the latest JavaScript features and provide additional features that help you to develop any kind of application that uses databases - from small applications with a few tables to large-scale enterprise applications with multiple databases.
TypeORM supports more databases than any other JS/TS ORM: Google Spanner, Microsoft SqlServer, MySQL/MariaDB, MongoDB, Oracle, Postgres, SAP HANA and SQLite, as well as derived databases and different drivers.
TypeORM supports both Active Record and Data Mapper patterns, unlike all other JavaScript ORMs currently in existence, which means you can write high-quality, loosely coupled, scalable, maintainable applications in the most productive way.
TypeORM is highly influenced by other ORMs, such as Hibernate, Doctrine and Entity Framework.
And more...
With TypeORM, your models look like this:
import { Entity, PrimaryGeneratedColumn, Column } from "typeorm"
@Entity()
export class User {
@PrimaryGeneratedColumn()
id: number
@Column()
firstName: string
@Column()
lastName: string
@Column()
age: number
}
And your domain logic looks like this:
const userRepository = MyDataSource.getRepository(User)
const user = new User()
user.firstName = "Timber"
user.lastName = "Saw"
user.age = 25
await userRepository.save(user)
const allUsers = await userRepository.find()
const firstUser = await userRepository.findOneBy({
id: 1,
}) // find by id
const timber = await userRepository.findOneBy({
firstName: "Timber",
lastName: "Saw",
}) // find by firstName and lastName
await userRepository.remove(timber)
Alternatively, if you prefer to use the ActiveRecord implementation, you can use it as well:
import { Entity, PrimaryGeneratedColumn, Column, BaseEntity } from "typeorm"
@Entity()
export class User extends BaseEntity {
@PrimaryGeneratedColumn()
id: number
@Column()
firstName: string
@Column()
lastName: string
@Column()
age: number
}
And your domain logic will look this way:
const user = new User()
user.firstName = "Timber"
user.lastName = "Saw"
user.age = 25
await user.save()
const allUsers = await User.find()
const firstUser = await User.findOneBy({
id: 1,
})
const timber = await User.findOneBy({
firstName: "Timber",
lastName: "Saw",
})
await timber.remove()
There are a few repositories that you can clone and start with:
There are several extensions that simplify working with TypeORM and integrating it with other modules:
data-source.ts after generating migrations/entities - typeorm-codebase-syncrelations objects - typeorm-relationsrelations based on a GraphQL query - typeorm-relations-graphqlLearn about contribution here and how to set up your development environment here.
This project exists thanks to all the people who contribute:
Open source is hard and time-consuming. If you want to invest in TypeORM's future, you can become a sponsor and allow our core team to spend more time on TypeORM's improvements and new features.
Become a champion sponsor and get premium technical support from our core contributors. Become a champion
Support TypeORM's development with a monthly contribution. Become a supporter
Join our community of supporters and help sustain TypeORM. Become a community supporter
Make a one-time or recurring contribution of your choice. Become a sponsor