Sequelize

A promise-based Node.js ORM for Postgres, MySQL, MariaDB, SQLite, and SQL Server with solid transaction support and rich associations.

Library
npm
v6.37.8
30,366stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
88/100Excellent
Development Activity84
Maintenance84
Community84
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
71/100Good
Architecture85
Code Quality82
Innovation55
Learning Curve60

Sequelize is a mature, promise-based ORM for Node.js that gives applications a single, consistent API over Postgres, MySQL, MariaDB, SQLite, Microsoft SQL Server, Snowflake, Oracle DB, and Db2. Rather than hand-writing dialect-specific SQL, developers define models and let Sequelize generate the queries, migrations, and schema-aware validation underneath.

The project has been the default ORM choice for Node.js backends for over a decade, with first-class support for associations (belongsTo, hasMany, belongsToMany), eager and lazy loading, optimistic locking, read replication, and transactions. A large monorepo of dialect packages (@sequelize/mysql, @sequelize/postgres, @sequelize/sqlite3, etc.) keeps database-specific behavior isolated behind a shared abstract-dialect interface.

The stable npm sequelize package tracks the v6 line, which remains the production-recommended release; the GitHub repository’s main branch is now mid-rewrite toward a TypeScript-first v7 (published as @sequelize/core), so day-to-day usage guidance and this package’s version history reflect v6 while the project’s ongoing development targets v7.

What You Get

  • Model definitions - declare tables as JavaScript/TypeScript classes with typed attributes, defaults, and validations instead of hand-written schema files
  • Associations - belongsTo, hasOne, hasMany, and belongsToMany with eager loading (include) and lazy loading resolved into a single query plan
  • Migrations & CLI tooling - the companion sequelize-cli generates and runs versioned migrations and seeders against any supported dialect
  • Transactions - managed and unmanaged transaction APIs with configurable isolation levels and automatic rollback on error
  • Multi-dialect query generation - one model definition compiles to correct SQL across Postgres, MySQL, MariaDB, SQLite, MSSQL, Snowflake, Oracle, and Db2
  • Connection pooling & read replication - built-in pool management and a read-replica configuration for scaling read-heavy workloads

Common Use Cases

  • REST/GraphQL API backends - Express or Fastify services use Sequelize models as the data-access layer between HTTP handlers and the database
  • Multi-tenant SaaS applications - schema-per-tenant or row-level tenancy built on Sequelize’s scoping and association APIs
  • Database migrations for legacy schemas - teams adopt Sequelize’s migration tooling to version-control schema changes on an existing production database
  • Cross-database portability - projects that need to support both Postgres in production and SQLite in local/test environments without maintaining two query layers

Under The Hood

Architecture The core package centers on a Sequelize class (src/sequelize.js, built on SequelizeTypeScript) and a Model class (src/model.js, ~4,700 lines) that resolves declared associations (associations/base.ts, has-many.ts, belongs-to.ts, belongs-to-many.ts, has-one.ts) into single query plans via eager-loading include options. Every database-specific behavior sits behind a shared AbstractDialect contract (abstract-dialect/dialect.ts, query-generator.ts, query-interface.ts, connection-manager.ts, replication-pool.ts) that each dialect package in the monorepo (@sequelize/postgres, @sequelize/mysql, @sequelize/mssql, @sequelize/sqlite3, @sequelize/mariadb, @sequelize/db2, @sequelize/oracle, @sequelize/snowflake, @sequelize/ibmi) implements independently; changing that abstract interface is the one change that ripples through every dialect package at once, which is exactly why dialect support is factored into a dozen separate workspace packages rather than one monolith.

Tech Stack @sequelize/core is written in TypeScript and ships dual ESM/CJS builds via a conditional exports map. Runtime dependencies are deliberately narrow: dayjs for dates, validator and its type-fest-typed wrapper for input validation, lodash and inflection for data/naming utilities, sequelize-pool for connection pooling, retry-as-promised for transient-failure retries, and toposort-class for dependency-ordered migration/association resolution. The whole project is a Yarn-workspaces monorepo orchestrated with Lerna and Nx (lerna.json, nx.json), targeting Node ^20.9/^22.11/>=24, with TypeDoc generating the published API reference from inline JSDoc.

Code Quality Testing is extensive and layered: test/unit for isolated logic, test/integration split per dialect (mariadb, mysql, postgres, sqlite3, mssql, db2, ibmi, snowflake, oracle), plus test/smoke and an ESM-named-exports regression suite, all run through Mocha/Chai/Sinon with nyc coverage. CI (.github/workflows/ci.yml) enforces ESLint (@ephys/eslint-config-typescript) and Prettier formatting, and a separate Semgrep workflow scans for security issues on every change. Comment density in core files like model.js is comprehensive, doubling as the source for the generated TypeDoc site.

API Design Getting started is low-boilerplate for the common case — extend Model, call .init() with an attribute map, and the same model works unmodified across a dozen SQL dialects, which is Sequelize’s main ergonomic bet over hand-rolled per-database query code. The tradeoff surfaces at the edges: the extensive hooks system and dialect-specific quirks (documented per-dialect in the compatibility table) require reading past the basic model API, and the in-progress rewrite toward a decorator-based @sequelize/core v7 means current v6 users and v7 early adopters are learning two overlapping but distinct APIs during the transition.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search