Documentation
    Preparing search index...

    Interface AggregateOptions<T, TAttributes>

    Options used for Model.aggregate

    interface AggregateOptions<T extends DataType | unknown, TAttributes = any> {
        benchmark?: boolean;
        bind?: BindOrReplacements;
        connection?: AbstractConnection | null;
        dataType?: string | T;
        distinct?: boolean;
        fieldMap?: FieldMap;
        instance?: Model<any, any>;
        logging?: false | ((sql: string, timing?: number) => void);
        mapToModel?: boolean;
        nest?: boolean;
        paranoid?: boolean;
        plain?: boolean;
        raw?: boolean;
        replacements?: BindOrReplacements;
        retry?: Options;
        supportsSearchPath?: boolean;
        transaction?: Transaction | null;
        type?: string;
        useMaster?: boolean;
        where?: WhereOptions<TAttributes>;
    }

    Type Parameters

    • T extends DataType | unknown
    • TAttributes = any

    Hierarchy (View Summary)

    Index
    benchmark?: boolean

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

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

    connection?: AbstractConnection | null

    The connection on which this query must be run. Mutually exclusive with Transactionable.transaction.

    Can be used to ensure that a query is run on the same connection as a previous query, which is useful when configuring session options.

    Specifying this option takes precedence over CLS Transactions. If a transaction is running in the current AsyncLocalStorage context, it will be ignored in favor of the specified connection.

    dataType?: string | T

    The type of the result. If attribute being aggregated is a defined in the Model, the default will be the type of that attribute, otherwise defaults to a plain JavaScript number.

    distinct?: boolean

    Applies DISTINCT to the field being aggregated over

    fieldMap?: FieldMap

    Map returned fields to arbitrary names for SELECT query type if options.fieldMaps is present.

    instance?: Model<any, any>

    A sequelize instance used to build the return instance

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

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

    mapToModel?: boolean

    Map returned fields to model's fields if options.model or options.instance is present. Mapping will occur before building the model instance.

    nest?: boolean

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

    true
    
    plain?: boolean

    Sets the query type to SELECT and return a single row

    raw?: boolean

    If true, sequelize will not try to format the results of the query, or build an instance of a model from the result

    replacements?: BindOrReplacements

    Either an object of named parameter replacements in the format :param or an array of unnamed replacements to replace ? in your SQL.

    retry?: Options
    supportsSearchPath?: boolean

    If false do not prepend the query with the search_path (Postgres only)

    transaction?: Transaction | null

    The transaction in which this query must be run. Mutually exclusive with Transactionable.connection.

    If the Sequelize disableClsTransactions option has not been set to true, and a transaction is running in the current AsyncLocalStorage context, that transaction will be used, unless null or another Transaction is manually specified here.

    type?: string

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

    useMaster?: boolean

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

    false
    

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