From 6dc8b36c674cead34d80e747a7687097da0b15a1 Mon Sep 17 00:00:00 2001 From: Yaroslav Date: Wed, 21 Mar 2018 14:35:15 +0200 Subject: [PATCH 1/2] Type "Buffer" as primary key in "findById" and its alias "findByPrimary" functions. --- types/sequelize/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/sequelize/index.d.ts b/types/sequelize/index.d.ts index a9b59a0766..74be4db7c3 100644 --- a/types/sequelize/index.d.ts +++ b/types/sequelize/index.d.ts @@ -3865,8 +3865,8 @@ declare namespace sequelize { * Search for a single instance by its primary key. This applies LIMIT 1, so the listener will * always be called with a single instance. */ - findById(identifier?: number | string, options?: FindOptions): Promise; - findByPrimary(identifier?: number | string, options?: FindOptions): Promise; + findById(identifier?: number | string | Buffer, options?: FindOptions): Promise; + findByPrimary(identifier?: number | string | Buffer, options?: FindOptions): Promise; /** * Search for a single instance. This applies LIMIT 1, so the listener will always be called with a single From 8522b56feb0754737a165a543ee617c26c3da4df Mon Sep 17 00:00:00 2001 From: Yaroslav Date: Wed, 21 Mar 2018 15:02:20 +0200 Subject: [PATCH 2/2] Tests --- types/sequelize/sequelize-tests.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/types/sequelize/sequelize-tests.ts b/types/sequelize/sequelize-tests.ts index f99988b29f..fb49abd88e 100644 --- a/types/sequelize/sequelize-tests.ts +++ b/types/sequelize/sequelize-tests.ts @@ -957,6 +957,12 @@ User.findAll( { where: { $or:[ { username: { $not: "user" } }, { theDate: new Da User.findAll( { where: { emails: { $overlap: ["me@mail.com", "you@mail.com"] } } } ); User.findById( 'a string' ); +User.findById( 42 ); +User.findById( Buffer.from('a buffer') ); + +User.findByPrimary( 'a string' ); +User.findByPrimary( 42 ); +User.findByPrimary( Buffer.from('a buffer') ); User.findOne( { where : { username : 'foo' } } ); User.findOne( { where : { id : 1 }, attributes : ['id', ['username', 'name']] } );