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,362 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
94 /100 Excellent
Development Activity 96
Maintenance 96
Community 84
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
71 /100 Good
Architecture 85
Code Quality 82
Innovation 55
Learning Curve 60

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.

Used by 5 apps in this directory

JavaScript
99%
Other

ChartBrew

Analytics · Databases

4,063

Open-source reporting platform to build live dashboards from SQL, NoSQL, APIs, and SaaS tools with an AI assistant that creates charts from natural language.

View details
90
Repo Health
83
Technical
64
Dependency
Built with
JavaScript 99%
Updated 1 weeks ago
TypeScript
99%
Other

NocoBase

Low Code Platforms · No Code Platforms

24,377

Open-source AI + no-code platform that lets coding agents and people collaborate to build business systems fast on proven infrastructure.

View details
94
Repo Health
81
Technical
63
Dependency
Built with
TypeScript 99%
Updated 6 days ago
TypeScript
97%
Other

Outline

Collaboration · Knowledge Management

40,729

A fast, real-time collaborative knowledge base for growing teams built on React, Node.js, and ProseMirror.

View details
91
Repo Health
87
Technical
68
Dependency
Built with
TypeScript 97%
Updated 6 days ago
TypeScript
91%
AGPL 3.0

PeerTube

Social Media

15,340

A federated, ActivityPub-based video hosting platform built by Framasoft — self-hostable instances interconnect into a network with no vendor lock-in, P2P-assisted streaming, and no ads.

View details
96
Repo Health
75
Technical
70
Dependency
Built with
TypeScript 91%
Updated 1 weeks ago
TypeScript
91%
MIT

SerpBear

Analytics · Marketing

2,093

Self-hosted keyword rank tracker with Google Search Console integration, multi-provider SERP scraping, and a built-in REST API.

View details
48
Repo Health
67
Technical
68
Dependency
Built with
TypeScript 91%
Updated 4 months ago

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