Merge pull request #24442 from YaroslavRepeta/buffer-as-primary-key

[Sequelize] Add type "Buffer" as possible primary key in "findById" and its alias "findByPrimary" functions
This commit is contained in:
Mine Starks
2018-03-22 12:27:43 -07:00
committed by GitHub
2 changed files with 8 additions and 2 deletions
+2 -2
View File
@@ -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<TCustomAttributes>(identifier?: number | string, options?: FindOptions<TAttributes & TCustomAttributes>): Promise<TInstance | null>;
findByPrimary<TCustomAttributes>(identifier?: number | string, options?: FindOptions<TAttributes & TCustomAttributes>): Promise<TInstance | null>;
findById<TCustomAttributes>(identifier?: number | string | Buffer, options?: FindOptions<TAttributes & TCustomAttributes>): Promise<TInstance | null>;
findByPrimary<TCustomAttributes>(identifier?: number | string | Buffer, options?: FindOptions<TAttributes & TCustomAttributes>): Promise<TInstance | null>;
/**
* Search for a single instance. This applies LIMIT 1, so the listener will always be called with a single
+6
View File
@@ -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']] } );