SEQ::DOCS
βŒ‚
Promise-Based ORM for SQL

Sequelize Complete Guide

Sequelize is a mature, promise-based Object-Relational Mapper for Node.js that works across PostgreSQL, MySQL, MariaDB, SQLite, and SQL Server. It maps JavaScript model classes directly onto relational tables, generating the SQL for you while adding built-in validation, lifecycle hooks, and a declarative way to describe associations between tables. This doc walks through the 8 things a backend engineer actually needs to know to use Sequelize well in production β€” in the order you'll naturally run into them β€” with a diagram, a "where to use it" guide, and concrete implementation steps for every single one.

8 topics 8 diagrams 1 ORM 5 supported dialects

Use the sidebar to jump straight to any topic β€” each one opens its own page with a full explanation, a diagram of how it fits together with the concepts around it, and the concrete steps (with real code) to actually use it. If you're starting from zero, work through the topics top to bottom: nothing past model definitions makes much sense without a working connection and at least one model in place.

Diagram Β· From JS Models to a Running Database
JS Models class extends Model Sequelize ORM engine Generated SQL dialect-specific PostgreSQL MySQL / others SUPPORTING CONCEPTS β€” MAKE THE ROW ABOVE SAFE & USABLE Migrations Associations Validations & Hooks Transactions Connection Pool sequelize-cli

Everything you write is a JS model; Sequelize translates it into the correct dialect's SQL and runs it against the actual database. Everything in the row below is what keeps that translation safe and predictable β€” schema changes go through migrations, relationships through associations, data integrity through validations and hooks, and multi-step writes through transactions.

All 8 topics in this guide

Summary & Patterns

Once the individual topics make sense on their own, these references tie them together: the order to learn them in, and the one diagram every Sequelize user eventually needs β€” how the three association types actually differ.

Recommended Learning Order

hasOne / hasMany / belongsToMany at a glance

Diagram Β· The Three Association Types
hasOne / belongsTo β€” one to one User 1 : 1 Profile hasMany / belongsTo β€” one to many User 1 : N Post Post Post belongsToMany β€” many to many, through a join table Post PostTag Tag N N

hasOne adds a foreign key that points at a single related row; hasMany is the same foreign key, just on the "many" side; belongsToMany needs a real intermediate table (PostTag) holding a foreign key to each side, since neither Post nor Tag can hold a column referencing multiple rows on the other side.

Official Documentation Reference URLs

Every topic covered in this guide, with a direct link to its official Sequelize v6 docs.