Reference
Find what you need by entity or by task. Items marked postgrelize extension are postgrelize extensions that Sequelize v6 does not have; the full list is on the extensions page.
By entity
| Entity | Guide | Options | API |
|---|---|---|---|
| Models and attributes | Models | Model options | Model |
| Data types | Data types | Model options | DataTypes |
| Decorators | Decorators | Model options | API index |
| Associations | Associations | Model options | Association |
| Finders, aggregates | Querying | Query options | Model.findAll |
| Scopes | Scopes | Query options | Model.scope |
| Writes | Querying, Upserts, Bulk writes | Write options | Model.create |
| Raw SQL | Raw SQL | Connection options | Sequelize.query |
| Transactions | Transactions | Connection options | Transaction |
| Hooks | Hooks and validation | Model options | HookRegistry |
| Validation | Validation | Model options | ValidationError |
| Errors | Errors | - | DatabaseError |
| Connection, pool | Connection | Connection options | Sequelize |
| Replicas, retry, sessions | Sessions and scaling | Connection options | ReplicationOptions |
| Schema, sync, DDL | Schema, Schema objects, Constraints and indexes | Schema options | QueryInterface |
By task
| I want to... | Use | Where |
|---|---|---|
| Define a model | sequelize.define, class extends Model + init, or decorators | Models, Decorators |
| Store JSON, arrays, ranges, UUIDs, geometry | DataTypes.JSONB, ARRAY, RANGE, UUID, geometric types | Models: data types |
| Use an identity or generated column | identity, generated attribute options postgrelize extension | Identity and generated columns |
| Filter rows with operators | where with Op | Filtering |
Search text (full-text, trigram, SIMILAR TO) | toTsQuery, tsRank, trigramSimilarity postgrelize extension | Operator and search helpers |
| Paginate | limit, offset; keyset with tuple postgrelize extension | Paginating, Keyset |
| Count and aggregate | count, sum, max, group | Aggregates |
| Load related rows | include | Eager loading |
| Take the latest N rows per parent | include with lateral postgrelize extension | LATERAL joins |
| Reuse a filter | scopes | Scopes |
| Run raw SQL safely | sequelize.query with replacements or bind | Raw SQL |
| Lock rows | lock, skipLocked, noWait postgrelize extension | Locking, Row locks |
| Insert or update in one statement | upsert, onConflict postgrelize extension | Upserts |
| Read old values after an update | returningOld postgrelize extension (PostgreSQL 18) | RETURNING OLD |
| Insert many rows quickly | bulkCreate with unnest postgrelize extension, copyFrom postgrelize extension | Bulk writes |
| Update or delete using another table | updateStatement, deleteStatement postgrelize extension | UPDATE ... FROM |
| Sync rows from a source table | Model.merge postgrelize extension | MERGE |
| Export a table | copyTo postgrelize extension | Export with copyTo |
| Process a huge table in batches | findEach postgrelize extension | findEach |
| Write recursive or multi-step queries | CTEs: with, source postgrelize extension | Common table expressions |
| Rank or number rows | over(...) window functions postgrelize extension | Window functions |
| Run several statements atomically | sequelize.transaction | Transactions |
| Pick an isolation level or read-only mode | isolationLevel, readOnly, deferrable postgrelize extension | Transactions |
| Serialize work across processes | withAdvisoryLock postgrelize extension | Advisory locks |
| Push events between processes | listen, notify postgrelize extension | LISTEN / NOTIFY |
| Send reads to replicas | replication postgrelize extension | Read replicas |
| Stop a slow query | statementTimeout postgrelize extension | Statement timeout |
| Retry transient failures | retry | Retrying |
| Handle a unique or foreign key violation | UniqueConstraintError, ForeignKeyConstraintError | Errors |
| Validate input | validators, validationSchema postgrelize extension (zod, valibot) | Hooks and validation |
| React to create / update / destroy | hooks | Hooks |
| Create tables, indexes and constraints | sync, QueryInterface.createTable, addIndex | Schema, Constraints and indexes |
| Use views, sequences, triggers, partitions, RLS | QueryInterface.createView, createPartition, createPolicy postgrelize extension | Schema objects, Partitioning |
| Tune pool size, logging, timezone | Sequelize constructor options | Connection |
| Move from Sequelize v6 | change the import | Migrating |