Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface CountOptions<TAttributes>

Options for Model.count method

Type parameters

  • TAttributes = any

Hierarchy

Index

Properties

If 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:

  • The first is the name of the attribute (or literal, fn, col),
  • and the second is the name to give to that attribute in the returned instance.

If include is used: selects all the attributes of the model, plus some additional ones. Useful for aggregations.

example
{ 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

example
{ attributes: { exclude: ['password'] } }
benchmark?: boolean

Pass query execution time in milliseconds as second argument to logging function (options.logging).

col?: string

Column on which COUNT() should be applied

distinct?: boolean

Apply COUNT(DISTINCT(col))

group?: GroupOption

GROUP BY in sql Used in conjunction with attributes.

see

Projectable

Include options. See find for details

logging?: boolean | ((sql: string, timing?: number) => void)

A function that gets executed while running the query to log the sql.

paranoid?: boolean

If true, only non-deleted records will be returned. If false, both deleted and non-deleted records will be returned.

Only applies if InitOptions.paranoid is true for the model.

default

true

transaction?: null | Transaction

The 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.

useMaster?: boolean

Force the query to use the write pool, regardless of the query type.

default

false

where?: WhereOptions<TAttributes>

The WHERE clause. Can be many things from a hash of attributes to raw SQL.

Generated using TypeDoc