TypeScript & JavaScript ORM for Node.js — supports PostgreSQL, MySQL, MariaDB, SQLite, SQL Server, Oracle, and more.
Find a file
Oleg "OSA413" Sokolov 90352ce59c
Some checks failed
Tests / detect-changes (push) Has been cancelled
Tests / format (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
Assign Milestone / assign-milestone (push) Has been cancelled
Tests / docs (push) Has been cancelled
Tests / build (push) Has been cancelled
Tests / lint (push) Has been cancelled
Tests / tests-linux (20) (push) Has been cancelled
Tests / tests-linux (24) (push) Has been cancelled
Tests / tests-windows (push) Has been cancelled
Tests / tests-codemod (push) Has been cancelled
Tests / tests-legacy-naming-strategies (push) Has been cancelled
Tests / coverage (push) Has been cancelled
Tests / all-passed (push) Has been cancelled
test: make Postgres custom extension installation test reusable locally (#12538)
2026-05-23 18:45:46 +05:00
.github chore(deps): bump the github-actions-third-party group across 1 directory with 2 updates (#12529) 2026-05-21 12:14:22 -04:00
.husky fix: do not run npm install during CLI init (#12386) 2026-04-18 10:11:08 +00:00
.vscode refactor!: remove app-root-path (#12257) 2026-04-15 10:50:27 +00:00
docker ci: use prettier on all types of files it supports (#11842) 2026-01-22 19:20:04 +01:00
docs chore(deps): bump webpack-dev-server from 5.2.3 to 5.2.4 in /docs (#12516) 2026-05-21 15:07:49 +00:00
extra refactor(decorator): remove deprecated @RelationCount decorator (#12181) 2026-03-11 19:05:06 +00:00
packages chore(legacy-naming-strategies): bump to 1.0.0 (#12518) 2026-05-19 13:36:06 +02:00
playground fix: use file reference for typeorm in playground to prevent false dependabot alerts (#12438) 2026-05-07 15:45:22 -04:00
resources fix(npm-readme): resolve missing image file pt. 2 (#11291) 2025-02-14 21:00:19 +01:00
src docs(data-source): clarify extra option as driver-native escape hatch (#12368) 2026-05-19 18:42:02 +00:00
test test: make Postgres custom extension installation test reusable locally (#12538) 2026-05-23 18:45:46 +05:00
.c8rc.json refactor(tests): ensure test files have the .test.ts extension (#11801) 2025-11-30 21:37:49 +01:00
.editorconfig ci: use prettier on all types of files it supports (#11842) 2026-01-22 19:20:04 +01:00
.gitignore refactor!: remove app-root-path (#12257) 2026-04-15 10:50:27 +00:00
.lintstagedrc.json docs(performance): add database-specific EXPLAIN examples to indexes guide (#12328) 2026-04-12 23:05:32 +00:00
.mocharc.json chore(deps): bump dependencies and fix lint offenses (#12401) 2026-04-22 21:11:41 +00:00
.pr_agent.toml chore: expand qodo with review-ux and self-review options (#12380) 2026-04-17 16:00:28 +00:00
.prettierignore build(gulp): remove gulpclass dependency and modernize build pipeline (#12224) 2026-03-17 21:17:41 +00:00
.prettierrc.js ci: use prettier on all types of files it supports (#11842) 2026-01-22 19:20:04 +01:00
CHANGELOG.md chore: release v1.0.0 (#12510) 2026-05-19 13:07:03 +02:00
CONTRIBUTING.md docs(security): route vulnerability reports to GitHub Security Advisories (#12359) 2026-04-20 19:59:42 +02:00
DEVELOPER.md ci(publish): overhaul publish package strategy with tagging (#12154) 2026-03-12 00:07:34 +00:00
docker-compose.yml ci(spanner): add spanner job to the linux test matrix (#12349) 2026-04-16 08:30:02 +00:00
eslint.config.mjs refactor!: extract legacy naming strategies (#12416) 2026-05-05 08:06:05 +02:00
gulpfile.ts fix(cli): preserve devDependencies needed by init command in published package (#12281) 2026-03-31 15:58:46 +02:00
LICENSE chore(license): update copyright year to 2025 (#11223) 2025-01-05 21:03:01 +01:00
ormconfig.sample.json ci(spanner): add spanner job to the linux test matrix (#12349) 2026-04-16 08:30:02 +00:00
package.json chore: release v1.0.0 (#12510) 2026-05-19 13:07:03 +02:00
pnpm-lock.yaml chore(deps): update all dependencies to their latest minor version (#12439) 2026-05-08 15:37:35 +02:00
pr_compliance_checklist.yaml chore(qodo-config): add compliance checklist (#11921) 2026-01-18 18:40:12 +02:00
README.md chore: remove legacy samples and move playground to root (#12403) 2026-04-23 13:48:54 +00:00
SECURITY.md docs(security): route vulnerability reports to GitHub Security Advisories (#12359) 2026-04-20 19:59:42 +02:00
sonar-project.properties ci: migrate code coverage from Coveralls to SonarCloud (#12274) 2026-04-17 09:49:37 +00:00
stryker.config.json ci: update github actions to latest versions (#12201) 2026-03-13 00:08:24 +00:00
tsconfig.browser.json build(gulp): remove gulpclass dependency and modernize build pipeline (#12224) 2026-03-17 21:17:41 +00:00
tsconfig.json refactor!: extract legacy naming strategies (#12416) 2026-05-05 08:06:05 +02:00
tsconfig.node.json build(gulp): remove gulpclass dependency and modernize build pipeline (#12224) 2026-03-17 21:17:41 +00:00

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.

Features

  • Supports both DataMapper and ActiveRecord (your choice).
  • Entities and columns.
  • Database-specific column types.
  • Entity manager.
  • Repositories and custom repositories.
  • Clean object-relational model.
  • Associations (relations).
  • Eager and lazy relations.
  • Unidirectional, bidirectional, and self-referenced relations.
  • Supports multiple inheritance patterns.
  • Cascades.
  • Indices.
  • Transactions.
  • Migrations and automatic migrations generation.
  • Connection pooling.
  • Replication.
  • Using multiple database instances.
  • Working with multiple database types.
  • Cross-database and cross-schema queries.
  • Elegant-syntax, flexible and powerful QueryBuilder.
  • Left and inner joins.
  • Proper pagination for queries using joins.
  • Query caching.
  • Streaming raw results.
  • Logging.
  • Listeners and subscribers (hooks).
  • Supports closure table pattern.
  • Schema declaration in models or separate configuration files.
  • Supports MySQL / MariaDB / Postgres / CockroachDB / SQLite / Microsoft SQL Server / Oracle / SAP Hana / sql.js.
  • Supports MongoDB NoSQL database.
  • Works in Node.js / Browser / Ionic / Cordova / React Native / NativeScript / Expo / Electron platforms.
  • TypeScript and JavaScript support.
  • ESM and CommonJS support.
  • Produced code is performant, flexible, clean, and maintainable.
  • Follows all possible best practices.
  • CLI.

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()

Samples

There are a few repositories that you can clone and start with:

Extensions

There are several extensions that simplify working with TypeORM and integrating it with other modules:

Contributing

Learn about contribution here and how to set up your development environment here.

This project exists thanks to all the people who contribute:

Sponsors

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.

Champion

Become a champion sponsor and get premium technical support from our core contributors. Become a champion

Supporter

Support TypeORM's development with a monthly contribution. Become a supporter

Community

Join our community of supporters and help sustain TypeORM. Become a community supporter

Sponsor

Make a one-time or recurring contribution of your choice. Become a sponsor