📄️ Data Types
📄️ Using sequelize in AWS Lambda
AWS Lambda is a serverless computing service that allows customers
📄️ Connection Pool
If you're connecting to the database from a single process, you should create only one Sequelize instance. Sequelize will set up a connection pool on initialization. This connection pool can be configured through the constructor's options parameter (using options.pool), as is shown in the following example:
📄️ Constraints & Circularities
Adding constraints between tables means that tables must be created in the database in a certain order, when using sequelize.sync. If Task has a reference to User, the User table must be created before the Task table can be created. This can sometimes lead to circular references, where Sequelize cannot find an order in which to sync. Imagine a scenario of documents and versions. A document can have multiple versions, and for convenience, a document has a reference to its current version.
📄️ Dialect-Specific Things
Underlying Connector Libraries
📄️ Extending Data Types
Most likely the type you are trying to implement is already included in our built-in DataTypes. If a new datatype is not included, this manual will show how to write it yourself.
📄️ Hooks
Hooks (also known as lifecycle events), are functions which are called before and after calls in sequelize are executed. For example, if you want to always set a value on a model before saving it, you can add a beforeUpdate hook.
📄️ Indexes
Sequelize supports adding indexes to the model definition which will be created on sequelize.sync().
📄️ Working with Legacy Tables
While out of the box Sequelize will seem a bit opinionated it's easy to work legacy tables and forward proof your application by defining (otherwise generated) table and field names.
📄️ Legal Notice
License
📄️ Migrations
Just like you use version control systems such as Git to manage changes in your source code, you can use migrations to keep track of changes to the database. With migrations you can transfer your existing database into another state and vice versa: Those state transitions are saved in migration files, which describe how to get to the new state and how to revert the changes in order to get back to the old state.
📄️ Naming Strategies
The underscored option
📄️ Optimistic Locking
Sequelize has built-in support for optimistic locking through a model instance version count.
📄️ Query Interface
An instance of Sequelize uses something called Query Interface to communicate to the database in a dialect-agnostic way. Most of the methods you've learned in this manual are implemented with the help of several methods from the query interface.
📄️ Read Replication
Sequelize supports read replication, i.e. having multiple servers that you can connect to when you want to do a SELECT query. When you do read replication, you specify one or more servers to act as read replicas, and one server to act as the main writer, which handles all writes and updates and propagates them to the replicas (note that the actual replication process is not handled by Sequelize, but should be set up by database backend).
📄️ Awesome Sequelize
A curated list of awesome projects surrounding Sequelize.
📄️ Scopes
Scopes are used to help you reuse code. You can define commonly used queries, specifying options such as where, include, limit, etc.
📄️ Sub Queries
Consider you have two models, Post and Reaction, with a One-to-Many relationship set up, so that one post has many reactions:
📄️ Transactions
Sequelize does not use transactions by default. However, for production-ready usage of Sequelize, you should definitely configure Sequelize to use transactions.
📄️ TypeScript
We're working hard on making Sequelize a breeze to use in TypeScript.
📄️ Upgrade to v7
Sequelize v7 is the next major release after v6. Below is a list of breaking changes to help you upgrade.
📄️ Who's using sequelize?
Walmart labs logo