$ open source · GPL-3.0 — need a commercial license? imqueue.com →

BaseModel.findByPk() method

Finds one instance by primary key.

Signature:

static findByPk<M>(identifier?: Identifier, options?: Omit<FindOptions, 'where'>): Promise<M | null>;

Parameters

Parameter

Type

Description

identifier

Identifier

(Optional) Primary key value to look for.

options

Omit<FindOptions, 'where'>

(Optional) Find options, minus where, which the key supplies.

Returns:

Promise<M | null>

The instance, or null when no row matches.

Remarks

Sequelize's own findByPk with one addition: on a model declared as a view, the numeric columns of the result are cast back to numbers.