Optional attributesOptional include?: (string | ProjectionAlias)[]Optional exclude?: string[]Optional benchmarkPass query execution time in milliseconds as second argument to logging function (options.logging).
Optional bindEither an object of named parameter bindings in the format $param or an array of unnamed
values to bind to $1, $2, etc in your SQL.
Optional byOptional fieldMap returned fields to arbitrary names for SELECT query type if options.fieldMaps is present.
Optional groupGROUP BY in sql
Optional groupedOptional havingSelect group rows after groups and aggregates are computed.
Optional includeA list of associations to eagerly load using a left join (a single association is also supported). Supported is either
{ include: Model1 }, { include: [ Model1, Model2, ...]}, { include: [{ model: Model1, as: 'Alias' }]} or
{ include: [{ all: true }]}.
If your association are set up with an as (eg. X.hasMany(Y, { as: 'Z' }, you need to specify Z in
the as attribute when eager loading Y).
Optional nested?: trueOptional indexMySQL only.
Optional instanceA sequelize instance used to build the return instance
Optional limitLimits how many items will be retrieved by the operation.
If limit and include are used together, Sequelize will turn the subQuery option on by default.
This is done to ensure that limit only impacts the Model on the same level as the limit option.
You can disable this behavior by explicitly setting subQuery: false, however limit will then
affect the total count of returned values, including eager-loaded associations, instead of just one table.
// in the following query, `limit` only affects the "User" model.
// This will return 2 users, each including all of their projects.
User.findAll({
limit: 2,
include: [User.associations.projects],
});
// in the following query, `limit` affects the total number of returned values, eager-loaded associations included.
// This may return 2 users, each with one project,
// or 1 user with 2 projects.
User.findAll({
limit: 2,
include: [User.associations.projects],
subQuery: false,
});
Optional lockLock the selected rows. Possible options are transaction.LOCK.UPDATE and transaction.LOCK.SHARE. Postgres also supports transaction.LOCK.KEY_SHARE, transaction.LOCK.NO_KEY_UPDATE and specific model locks with joins. See transaction.LOCK for an example
Optional loggingA function that gets executed while running the query to log the sql.
Optional timing: numberOptional mapMap returned fields to model's fields if options.model or options.instance is present.
Mapping will occur before building the model instance.
Optional middlewareOptional nestIf true, transforms objects with . separated property names into nested objects using
dottie.js. For example { 'user.username': 'john' } becomes
{ user: { username: 'john' }}. When nest is true, the query type is assumed to be 'SELECT',
unless otherwise specified
false
Optional offsetSkip the results;
Optional orderSpecifies an ordering. If a string is provided, it will be escaped. Using an array, you can provide
several columns / functions to order by. Each element can be further wrapped in a two-element array. The
first element is the column / function to order by, the second is the direction. For example:
order: [['name', 'DESC']]. In this way the column will be escaped, but the direction will not.
Optional paranoidIf true, only non-deleted records will be returned. If false, both deleted and non-deleted records will
be returned. Only applies if options.paranoid is true for the model.
Optional plainSets the query type to SELECT and return a single row
Optional rawReturn raw result. See sequelize.query for more information.
Optional replacementsEither an object of named parameter replacements in the format :param or an array of unnamed
replacements to replace ? in your SQL.
Optional retryOptional skipSkip locked rows. Only supported in Postgres.
Optional subUse sub queries (internal).
If unspecified, this will true by default if limit is specified, and false otherwise.
See FindOptions#limit for more information.
Optional transactionTransaction to run query under
Optional typeThe type of query you are executing. The query type affects how results are formatted before they are
passed back. The type is a string, but Sequelize.QueryTypes is provided as convenience shortcuts.
Optional useForce the query to use the write pool, regardless of the query type.
false
A list of the attributes that you want to select. To rename an attribute, you can pass an array, with two elements - the first is the name of the attribute in the DB (or some kind of expression such as
Sequelize.literal,Sequelize.fnand so on), and the second is the name you want the attribute to have in the returned instance