Optional
attributesIf an array: a list of the attributes that you want to select.
Attributes can also be raw SQL (literal
), fn
, and col
To rename an attribute, you can pass an array, with two elements:
literal
, fn
, col
),If include
is used: selects all the attributes of the model,
plus some additional ones. Useful for aggregations.
{ attributes: { include: [[literal('COUNT(id)'), 'total']] }
If exclude
is used: selects all the attributes of the model,
except the one specified in exclude. Useful for security purposes
{ attributes: { exclude: ['password'] } }
Optional
benchmarkPass query execution time in milliseconds as second argument to logging function (options.logging).
Optional
colColumn on which COUNT() should be applied
Optional
distinctApply COUNT(DISTINCT(col))
Optional
groupGROUP BY in sql
Used in conjunction with attributes
.
Projectable
Optional
includeInclude options. See find
for details
Optional
loggingA function that gets executed while running the query to log the sql.
Optional
paranoidIf true, only non-deleted records will be returned. If false, both deleted and non-deleted records will be returned.
Only applies if paranoid is true for the model.
true
Optional
transactionThe transaction in which this query must be run.
If CLS is enabled and a transaction is running in the current CLS context, that transaction will be used, unless null or a Transaction is manually specified here.
Optional
useForce the query to use the write pool, regardless of the query type.
false
Optional
whereThe WHERE
clause. Can be many things from a hash of attributes to raw SQL.
Visit https://sequelize.org/docs/v7/core-concepts/model-querying-basics/ for more information.
Generated using TypeDoc
Options for Model.count method