From fe4b22d147bba8a1a87bca37128d676584088d1c Mon Sep 17 00:00:00 2001 From: haracejacob Date: Mon, 11 Mar 2019 19:24:03 +0900 Subject: [PATCH] Add where type to WhereOptions --- types/sequelize/index.d.ts | 2 +- types/sequelize/sequelize-tests.ts | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/types/sequelize/index.d.ts b/types/sequelize/index.d.ts index 9aba040234..f2a9d5f5b1 100644 --- a/types/sequelize/index.d.ts +++ b/types/sequelize/index.d.ts @@ -3198,7 +3198,7 @@ declare namespace sequelize { */ type Primitives = string | number | boolean | Buffer; type WhereOptions = { - [P in keyof T]?: Primitives | Array | WhereLogic | (T[P] extends Primitives ? null : WhereOptions) | col | and | or | WhereGeometryOptions | WhereNested | null; + [P in keyof T]?: Primitives | Array | WhereLogic | (T[P] extends Primitives ? null : WhereOptions) | col | and | or | WhereGeometryOptions | WhereNested | where | null; }; /** diff --git a/types/sequelize/sequelize-tests.ts b/types/sequelize/sequelize-tests.ts index 3a13906f06..3c91281a0c 100644 --- a/types/sequelize/sequelize-tests.ts +++ b/types/sequelize/sequelize-tests.ts @@ -997,6 +997,9 @@ User.findAll( { where: { $and:[ { username: { $not: "user" } }, { theDate: new D User.findAll( { where: { $or:[ { username: { $not: "user" } }, { theDate: new Date() } ] } } ); User.findAll( { where: { emails: { $overlap: ["me@mail.com", "you@mail.com"] } } } ); +var options: Sequelize.AnyFindOptions = { where: { $and: Sequelize.where( Sequelize.fn( 'char_length', Sequelize.col('username') ), 4 ) } }; +User.findAll( options ); + User.findById( 'a string' ); User.findById( 42 ); User.findById( Buffer.from('a buffer') );