Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
T

typeorm

> 编程语言
Free

TypeScript & JavaScript ORM for Node.js — supports PostgreSQL, MySQL, MariaDB, SQLite, SQL Server, O

36.7K stars0 likes4 views
WebsiteGitHub

About

TypeScript & JavaScript ORM for Node.js — supports PostgreSQL, MySQL, MariaDB, SQLite, SQL Server, O

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:

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

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

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

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

  • Example how to use TypeORM with TypeScript
  • Example how to use TypeORM with JavaScript
  • Example how to use TypeORM with JavaScript and Babel
  • Example how to use TypeORM with TypeScript and SystemJS in Browser
  • Example how to use TypeORM with TypeScript and React in Browser
  • Example how to use Express and TypeORM
  • Example how to use Koa and TypeORM
  • Example how to use TypeORM with MongoDB
  • Example how to use TypeORM in a Cordova app
  • Example how to use TypeORM with an Ionic app
  • Example how to use TypeORM with React Native
  • Example how to use TypeORM with Nativescript-Vue
  • Example how to use TypeORM with Nativescript-Angular
  • Example how to use TypeORM with Electron using JavaScript
  • Example how to use TypeORM with Electron using TypeScript

Extensions

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

  • Models generation from the existing database - typeorm-model-generator
  • Fixtures loader - typeorm-fixtures-cli
  • ER Diagram generator - typeorm-uml
  • another ER Diagram generator - erdia
  • Create, drop and seed database - typeorm-extension
  • Automatically update data-source.ts after generating migrations/entities - typeorm-codebase-sync
  • Easy manipulation of relations objects - typeorm-relations
  • Automatically generate relations based on a GraphQL query - typeorm-relations-graphql
  • Generate TypeORM entities from Valibot schemas - piying-orm
  • Apply REST API query parameters (fields, filters, relations, pagination, sort) to a query builder - rapiq

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

Issues· 680 open

View all issuesOpen on GitHub
  • #12913

    Explicit resource management transaction handling

    Updated Sep 30, 2026
  • #12912

    docs: explain how to review PostgreSQL migration lock risk

    Updated Sep 29, 2026
  • #12904

    Closure-table reparenting leaves stale ancestors when a primary column is renamed

    Updated Sep 26, 2026
  • #12903

    Removing a nested-set ancestor and descendant together corrupts surviving tree bounds

    Updated Sep 26, 2026
  • #12902

    Composite string primary keys containing underscores collapse distinct entities during hydration

    Updated Sep 26, 2026
  • #10724

    Pointing to migrations folder creates an import error

    bugUpdated Sep 23, 2026
  • #10348

    Using synchronization: false with @Index does not ignore the index when creating migrations

    bugUpdated Sep 23, 2026
  • #11480

    Bug with typeorm and Migration and entity decorator

    Updated Sep 23, 2026
  • #12874

    Support per-dialect column types on @Column, e.g. dialectTypes: { postgres: 'jsonb' }

    Updated Sep 23, 2026
  • #11571

    uuid_generate_v4 function for postgres migration

    bugUpdated Sep 23, 2026

> Tags

TypeScriptactive-recordcockroachdbdata-mapper

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedOct 14, 2026
Category编程语言
PricingFree

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言