interface getOneOptions {
    attributes?: sequelizeFunc<undefined> | (string | ProjectionAlias)[] | {
        exclude: string[];
        include?: (string | ProjectionAlias)[];
    } | {
        exclude?: string[];
        include: (string | ProjectionAlias)[];
    } | sequelizeFunc<(string | ProjectionAlias)[]> | sequelizeFunc<{
        exclude: string[];
        include?: (string | ProjectionAlias)[];
    }> | sequelizeFunc<{
        exclude?: string[];
        include: (string | ProjectionAlias)[];
    }>;
    benchmark?: boolean | sequelizeFunc<undefined> | sequelizeFunc<false> | sequelizeFunc<true>;
    bind?: unknown[] | sequelizeFunc<undefined> | {
        [key: string]: unknown;
    } | sequelizeFunc<unknown[]> | sequelizeFunc<{
        [key: string]: unknown;
    }>;
    byField?: string;
    fieldMap?: sequelizeFunc<undefined> | FieldMap | sequelizeFunc<FieldMap>;
    group?: string | Fn | Col | sequelizeFunc<undefined> | sequelizeFunc<string> | sequelizeFunc<Fn> | sequelizeFunc<Col> | (string | Fn | Col)[] | sequelizeFunc<(string | Fn | Col)[]>;
    groupedLimit?: unknown;
    having?: Fn | Literal | Where | Json | WhereAttributeHash<any> | sequelizeFunc<undefined> | sequelizeFunc<Fn> | sequelizeFunc<Literal> | {
        [or]: AllowArray<AllowNotOrAndWithImplicitAndArrayRecursive<Fn | Literal | Where | Json | WhereAttributeHash<any>>>;
    } | {
        [and]: AllowArray<AllowNotOrAndWithImplicitAndArrayRecursive<Fn | Literal | Where | Json | WhereAttributeHash<any>>>;
    } | {
        [not]: AllowNotOrAndWithImplicitAndArrayRecursive<Fn | Literal | Where | Json | WhereAttributeHash<any>>;
    } | (Fn | Literal | Where | Json | WhereAttributeHash<any> | {
        [or]: AllowArray<AllowNotOrAndWithImplicitAndArrayRecursive<Fn | Literal | Where | Json | WhereAttributeHash<any>>>;
    } | {
        [and]: AllowArray<AllowNotOrAndWithImplicitAndArrayRecursive<Fn | Literal | Where | Json | WhereAttributeHash<any>>>;
    } | {
        [not]: AllowNotOrAndWithImplicitAndArrayRecursive<Fn | Literal | Where | Json | WhereAttributeHash<any>>;
    })[] | sequelizeFunc<Where> | sequelizeFunc<Json> | sequelizeFunc<WhereAttributeHash<any>> | sequelizeFunc<{
        [or]: AllowArray<AllowNotOrAndWithImplicitAndArrayRecursive<Fn | Literal | Where | Json | WhereAttributeHash<any>>>;
    }> | sequelizeFunc<{
        [and]: AllowArray<AllowNotOrAndWithImplicitAndArrayRecursive<Fn | Literal | Where | Json | WhereAttributeHash<any>>>;
    }> | sequelizeFunc<{
        [not]: AllowNotOrAndWithImplicitAndArrayRecursive<Fn | Literal | Where | Json | WhereAttributeHash<any>>;
    }> | sequelizeFunc<(Fn | Literal | Where | Json | WhereAttributeHash<any> | {
        [or]: AllowArray<AllowNotOrAndWithImplicitAndArrayRecursive<Fn | Literal | Where | Json | WhereAttributeHash<any>>>;
    } | {
        [and]: AllowArray<AllowNotOrAndWithImplicitAndArrayRecursive<Fn | Literal | Where | Json | WhereAttributeHash<any>>>;
    } | {
        [not]: AllowNotOrAndWithImplicitAndArrayRecursive<Fn | Literal | Where | Json | WhereAttributeHash<any>>;
    })[]>;
    include?: string | ModelType<any, any> | Association<Model<any, any>, Model<any, any>> | IncludeOptions | {
        all: true;
        nested?: true;
    } | Includeable[] | sequelizeFunc<undefined> | sequelizeFunc<string> | sequelizeFunc<ModelType<any, any>> | sequelizeFunc<Association<Model<any, any>, Model<any, any>>> | sequelizeFunc<IncludeOptions> | sequelizeFunc<{
        all: true;
        nested?: true;
    }> | sequelizeFunc<Includeable[]>;
    indexHints?: sequelizeFunc<undefined> | IndexHint[] | sequelizeFunc<IndexHint[]>;
    instance?: Model<any, any> | sequelizeFunc<undefined> | sequelizeFunc<Model<any, any>>;
    limit?: number | sequelizeFunc<undefined> | sequelizeFunc<number>;
    lock?: boolean | sequelizeFunc<undefined> | UPDATE | SHARE | KEY_SHARE | NO_KEY_UPDATE | {
        level: LOCK;
        of: ModelStatic<Model<any, any>>;
    } | sequelizeFunc<false> | sequelizeFunc<true> | sequelizeFunc<UPDATE> | sequelizeFunc<SHARE> | sequelizeFunc<KEY_SHARE> | sequelizeFunc<NO_KEY_UPDATE> | sequelizeFunc<{
        level: LOCK;
        of: ModelStatic<Model<any, any>>;
    }>;
    logging?: boolean | sequelizeFunc<undefined> | sequelizeFunc<false> | sequelizeFunc<true> | ((sql, timing?) => void) | sequelizeFunc<((sql, timing?) => void)>;
    mapToModel?: boolean | sequelizeFunc<undefined> | sequelizeFunc<false> | sequelizeFunc<true>;
    middleware?: expressFunc;
    nest?: boolean | sequelizeFunc<undefined> | sequelizeFunc<false> | sequelizeFunc<true>;
    offset?: number | sequelizeFunc<undefined> | sequelizeFunc<number>;
    order?: Fn | Col | Literal | OrderItem[] | sequelizeFunc<undefined> | sequelizeFunc<Fn> | sequelizeFunc<Col> | sequelizeFunc<Literal> | sequelizeFunc<OrderItem[]>;
    paranoid?: boolean | sequelizeFunc<undefined> | sequelizeFunc<false> | sequelizeFunc<true>;
    plain?: boolean | sequelizeFunc<undefined> | sequelizeFunc<false> | sequelizeFunc<true>;
    raw?: boolean | sequelizeFunc<undefined> | sequelizeFunc<false> | sequelizeFunc<true>;
    replacements?: unknown[] | sequelizeFunc<undefined> | {
        [key: string]: unknown;
    } | sequelizeFunc<unknown[]> | sequelizeFunc<{
        [key: string]: unknown;
    }>;
    retry?: sequelizeFunc<undefined> | Options | sequelizeFunc<Options>;
    skipLocked?: boolean | sequelizeFunc<undefined> | sequelizeFunc<false> | sequelizeFunc<true>;
    subQuery?: boolean | sequelizeFunc<undefined> | sequelizeFunc<false> | sequelizeFunc<true>;
    transaction?: null | sequelizeFunc<undefined> | Transaction | sequelizeFunc<null> | sequelizeFunc<Transaction>;
    type?: string | sequelizeFunc<undefined> | sequelizeFunc<string>;
    useMaster?: boolean | sequelizeFunc<undefined> | sequelizeFunc<false> | sequelizeFunc<true>;
}

Hierarchy (view full)

  • operationFieldCore
  • expressCrudProps<Omit<NonNullFindOptions<Attributes<Model>>, "where" | "rejectOnEmpty">>
    • getOneOptions

Properties

attributes?: sequelizeFunc<undefined> | (string | ProjectionAlias)[] | {
    exclude: string[];
    include?: (string | ProjectionAlias)[];
} | {
    exclude?: string[];
    include: (string | ProjectionAlias)[];
} | sequelizeFunc<(string | ProjectionAlias)[]> | sequelizeFunc<{
    exclude: string[];
    include?: (string | ProjectionAlias)[];
}> | sequelizeFunc<{
    exclude?: string[];
    include: (string | ProjectionAlias)[];
}>

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.fn and so on), and the second is the name you want the attribute to have in the returned instance

Type declaration

  • exclude: string[]
  • Optional include?: (string | ProjectionAlias)[]

Type declaration

  • Optional exclude?: string[]
  • include: (string | ProjectionAlias)[]
benchmark?: boolean | sequelizeFunc<undefined> | sequelizeFunc<false> | sequelizeFunc<true>

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

bind?: unknown[] | sequelizeFunc<undefined> | {
    [key: string]: unknown;
} | sequelizeFunc<unknown[]> | sequelizeFunc<{
    [key: string]: unknown;
}>

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.

Type declaration

  • [key: string]: unknown
byField?: string
fieldMap?: sequelizeFunc<undefined> | FieldMap | sequelizeFunc<FieldMap>

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

group?: string | Fn | Col | sequelizeFunc<undefined> | sequelizeFunc<string> | sequelizeFunc<Fn> | sequelizeFunc<Col> | (string | Fn | Col)[] | sequelizeFunc<(string | Fn | Col)[]>

GROUP BY in sql

groupedLimit?: unknown
having?: Fn | Literal | Where | Json | WhereAttributeHash<any> | sequelizeFunc<undefined> | sequelizeFunc<Fn> | sequelizeFunc<Literal> | {
    [or]: AllowArray<AllowNotOrAndWithImplicitAndArrayRecursive<Fn | Literal | Where | Json | WhereAttributeHash<any>>>;
} | {
    [and]: AllowArray<AllowNotOrAndWithImplicitAndArrayRecursive<Fn | Literal | Where | Json | WhereAttributeHash<any>>>;
} | {
    [not]: AllowNotOrAndWithImplicitAndArrayRecursive<Fn | Literal | Where | Json | WhereAttributeHash<any>>;
} | (Fn | Literal | Where | Json | WhereAttributeHash<any> | {
    [or]: AllowArray<AllowNotOrAndWithImplicitAndArrayRecursive<Fn | Literal | Where | Json | WhereAttributeHash<any>>>;
} | {
    [and]: AllowArray<AllowNotOrAndWithImplicitAndArrayRecursive<Fn | Literal | Where | Json | WhereAttributeHash<any>>>;
} | {
    [not]: AllowNotOrAndWithImplicitAndArrayRecursive<Fn | Literal | Where | Json | WhereAttributeHash<any>>;
})[] | sequelizeFunc<Where> | sequelizeFunc<Json> | sequelizeFunc<WhereAttributeHash<any>> | sequelizeFunc<{
    [or]: AllowArray<AllowNotOrAndWithImplicitAndArrayRecursive<Fn | Literal | Where | Json | WhereAttributeHash<any>>>;
}> | sequelizeFunc<{
    [and]: AllowArray<AllowNotOrAndWithImplicitAndArrayRecursive<Fn | Literal | Where | Json | WhereAttributeHash<any>>>;
}> | sequelizeFunc<{
    [not]: AllowNotOrAndWithImplicitAndArrayRecursive<Fn | Literal | Where | Json | WhereAttributeHash<any>>;
}> | sequelizeFunc<(Fn | Literal | Where | Json | WhereAttributeHash<any> | {
    [or]: AllowArray<AllowNotOrAndWithImplicitAndArrayRecursive<Fn | Literal | Where | Json | WhereAttributeHash<any>>>;
} | {
    [and]: AllowArray<AllowNotOrAndWithImplicitAndArrayRecursive<Fn | Literal | Where | Json | WhereAttributeHash<any>>>;
} | {
    [not]: AllowNotOrAndWithImplicitAndArrayRecursive<Fn | Literal | Where | Json | WhereAttributeHash<any>>;
})[]>

Select group rows after groups and aggregates are computed.

Type declaration

  • [or]: AllowArray<AllowNotOrAndWithImplicitAndArrayRecursive<Fn | Literal | Where | Json | WhereAttributeHash<any>>>

Type declaration

  • [and]: AllowArray<AllowNotOrAndWithImplicitAndArrayRecursive<Fn | Literal | Where | Json | WhereAttributeHash<any>>>

Type declaration

  • [not]: AllowNotOrAndWithImplicitAndArrayRecursive<Fn | Literal | Where | Json | WhereAttributeHash<any>>
include?: string | ModelType<any, any> | Association<Model<any, any>, Model<any, any>> | IncludeOptions | {
    all: true;
    nested?: true;
} | Includeable[] | sequelizeFunc<undefined> | sequelizeFunc<string> | sequelizeFunc<ModelType<any, any>> | sequelizeFunc<Association<Model<any, any>, Model<any, any>>> | sequelizeFunc<IncludeOptions> | sequelizeFunc<{
    all: true;
    nested?: true;
}> | sequelizeFunc<Includeable[]>

A 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).

Type declaration

  • all: true
  • Optional nested?: true
indexHints?: sequelizeFunc<undefined> | IndexHint[] | sequelizeFunc<IndexHint[]>

MySQL only.

instance?: Model<any, any> | sequelizeFunc<undefined> | sequelizeFunc<Model<any, any>>

A sequelize instance used to build the return instance

limit?: number | sequelizeFunc<undefined> | sequelizeFunc<number>

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

Example

// 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],
});

Example

// 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,
});
lock?: boolean | sequelizeFunc<undefined> | UPDATE | SHARE | KEY_SHARE | NO_KEY_UPDATE | {
    level: LOCK;
    of: ModelStatic<Model<any, any>>;
} | sequelizeFunc<false> | sequelizeFunc<true> | sequelizeFunc<UPDATE> | sequelizeFunc<SHARE> | sequelizeFunc<KEY_SHARE> | sequelizeFunc<NO_KEY_UPDATE> | sequelizeFunc<{
    level: LOCK;
    of: ModelStatic<Model<any, any>>;
}>

Lock 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

Type declaration

  • level: LOCK
  • of: ModelStatic<Model<any, any>>
logging?: boolean | sequelizeFunc<undefined> | sequelizeFunc<false> | sequelizeFunc<true> | ((sql, timing?) => void) | sequelizeFunc<((sql, timing?) => void)>

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

Type declaration

    • (sql, timing?): void
    • Parameters

      • sql: string
      • Optional timing: number

      Returns void

mapToModel?: boolean | sequelizeFunc<undefined> | sequelizeFunc<false> | sequelizeFunc<true>

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

middleware?: expressFunc
nest?: boolean | sequelizeFunc<undefined> | sequelizeFunc<false> | sequelizeFunc<true>

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

Default

false
offset?: number | sequelizeFunc<undefined> | sequelizeFunc<number>

Skip the results;

order?: Fn | Col | Literal | OrderItem[] | sequelizeFunc<undefined> | sequelizeFunc<Fn> | sequelizeFunc<Col> | sequelizeFunc<Literal> | sequelizeFunc<OrderItem[]>

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

paranoid?: boolean | sequelizeFunc<undefined> | sequelizeFunc<false> | sequelizeFunc<true>

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

plain?: boolean | sequelizeFunc<undefined> | sequelizeFunc<false> | sequelizeFunc<true>

Sets the query type to SELECT and return a single row

raw?: boolean | sequelizeFunc<undefined> | sequelizeFunc<false> | sequelizeFunc<true>

Return raw result. See sequelize.query for more information.

replacements?: unknown[] | sequelizeFunc<undefined> | {
    [key: string]: unknown;
} | sequelizeFunc<unknown[]> | sequelizeFunc<{
    [key: string]: unknown;
}>

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

Type declaration

  • [key: string]: unknown
retry?: sequelizeFunc<undefined> | Options | sequelizeFunc<Options>
skipLocked?: boolean | sequelizeFunc<undefined> | sequelizeFunc<false> | sequelizeFunc<true>

Skip locked rows. Only supported in Postgres.

subQuery?: boolean | sequelizeFunc<undefined> | sequelizeFunc<false> | sequelizeFunc<true>

Use sub queries (internal).

If unspecified, this will true by default if limit is specified, and false otherwise. See FindOptions#limit for more information.

transaction?: null | sequelizeFunc<undefined> | Transaction | sequelizeFunc<null> | sequelizeFunc<Transaction>

Transaction to run query under

type?: string | sequelizeFunc<undefined> | sequelizeFunc<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 | sequelizeFunc<undefined> | sequelizeFunc<false> | sequelizeFunc<true>

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

Default

false