mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 14:20:12 +00:00
[@types/sequelize] Removed the where property from options of findById, findByPrimary and findByPk (#35735)
* [@types/sequelize] Removed the where property from options of findById, findByPrimary and findByPk * [@types/sequelize] Added test cases for passing options to findById, findByPrimary and findByPk
This commit is contained in:
18
types/sequelize/index.d.ts
vendored
18
types/sequelize/index.d.ts
vendored
@@ -19,6 +19,7 @@
|
||||
// Duy Truong <https://github.com/truongkhanhduy95>
|
||||
// Emmanuel Gautier <https://github.com/emmanuelgautier>
|
||||
// Dan Rumney <https://github.com/dancrumb>
|
||||
// Kan Yueh Chen <https://github.com/lalayueh>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.2
|
||||
|
||||
@@ -36,6 +37,8 @@ import * as _ from "lodash";
|
||||
import Promise = require("bluebird");
|
||||
import * as cls from "continuation-local-storage"
|
||||
|
||||
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>
|
||||
|
||||
declare namespace sequelize {
|
||||
|
||||
//
|
||||
@@ -3939,9 +3942,18 @@ 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 | Buffer, options?: FindOptions<TAttributes & TCustomAttributes>): Promise<TInstance | null>;
|
||||
findByPrimary<TCustomAttributes>(identifier?: number | string | Buffer, options?: FindOptions<TAttributes & TCustomAttributes>): Promise<TInstance | null>;
|
||||
findByPk<TCustomAttributes>(identifier?: number | string | Buffer, options?: FindOptions<TAttributes & TCustomAttributes>): Promise<TInstance | null>;
|
||||
findById<TCustomAttributes>(
|
||||
identifier?: number | string | Buffer,
|
||||
options?: Omit<FindOptions<TAttributes & TCustomAttributes>, 'where'>,
|
||||
): Promise<TInstance | null>;
|
||||
findByPrimary<TCustomAttributes>(
|
||||
identifier?: number | string | Buffer,
|
||||
options?: Omit<FindOptions<TAttributes & TCustomAttributes>, 'where'>,
|
||||
): Promise<TInstance | null>;
|
||||
findByPk<TCustomAttributes>(
|
||||
identifier?: number | string | Buffer,
|
||||
options?: Omit<FindOptions<TAttributes & TCustomAttributes>, 'where'>,
|
||||
): Promise<TInstance | null>;
|
||||
|
||||
/**
|
||||
* Search for a single instance. This applies LIMIT 1, so the listener will always be called with a single
|
||||
|
||||
@@ -1008,17 +1008,81 @@ 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') );
|
||||
User.findById( 1 );
|
||||
User.findById( 1, { attributes : ['id'] } );
|
||||
User.findById( 1, { logging : function( ) { } } );
|
||||
User.findById( 1, { transaction : t } );
|
||||
User.findById( 1, { include : [User] } );
|
||||
User.findById( 1, { include : [{ model : User }] });
|
||||
User.findById( 1, { include : [{ model : User, as : 'ToDo' }] });
|
||||
User.findById( 1, { include : [User, { model : User, as : 'ToDo' }] });
|
||||
User.findById( 'id' );
|
||||
User.findById( 'id', { attributes : ['id'] } );
|
||||
User.findById( 'id', { logging : function( ) { } } );
|
||||
User.findById( 'id', { transaction : t } );
|
||||
User.findById( 'id', { include : [User] } );
|
||||
User.findById( 'id', { include : [{ model : User }] });
|
||||
User.findById( 'id', { include : [{ model : User, as : 'ToDo' }] });
|
||||
User.findById( 'id', { include : [User, { model : User, as : 'ToDo' }] });
|
||||
User.findById( Buffer.from('id') );
|
||||
User.findById( Buffer.from('id'), { attributes : ['id'] } );
|
||||
User.findById( Buffer.from('id'), { logging : function( ) { } } );
|
||||
User.findById( Buffer.from('id'), { transaction : t } );
|
||||
User.findById( Buffer.from('id'), { include : [User] } );
|
||||
User.findById( Buffer.from('id'), { include : [{ model : User }] });
|
||||
User.findById( Buffer.from('id'), { include : [{ model : User, as : 'ToDo' }] });
|
||||
User.findById( Buffer.from('id'), { include : [User, { model : User, as : 'ToDo' }] });
|
||||
|
||||
User.findByPrimary( 'a string' );
|
||||
User.findByPrimary( 42 );
|
||||
User.findByPrimary( Buffer.from('a buffer') );
|
||||
User.findByPrimary( 1 );
|
||||
User.findByPrimary( 1, { attributes : ['id'] } );
|
||||
User.findByPrimary( 1, { logging : function( ) { } } );
|
||||
User.findByPrimary( 1, { transaction : t } );
|
||||
User.findByPrimary( 1, { include : [User] } );
|
||||
User.findByPrimary( 1, { include : [{ model : User }] });
|
||||
User.findByPrimary( 1, { include : [{ model : User, as : 'ToDo' }] });
|
||||
User.findByPrimary( 1, { include : [User, { model : User, as : 'ToDo' }] });
|
||||
User.findByPrimary( 'id' );
|
||||
User.findByPrimary( 'id', { attributes : ['id'] } );
|
||||
User.findByPrimary( 'id', { logging : function( ) { } } );
|
||||
User.findByPrimary( 'id', { transaction : t } );
|
||||
User.findByPrimary( 'id', { include : [User] } );
|
||||
User.findByPrimary( 'id', { include : [{ model : User }] });
|
||||
User.findByPrimary( 'id', { include : [{ model : User, as : 'ToDo' }] });
|
||||
User.findByPrimary( 'id', { include : [User, { model : User, as : 'ToDo' }] });
|
||||
User.findByPrimary( Buffer.from('id') );
|
||||
User.findByPrimary( Buffer.from('id'), { attributes : ['id'] } );
|
||||
User.findByPrimary( Buffer.from('id'), { logging : function( ) { } } );
|
||||
User.findByPrimary( Buffer.from('id'), { transaction : t } );
|
||||
User.findByPrimary( Buffer.from('id'), { include : [User] } );
|
||||
User.findByPrimary( Buffer.from('id'), { include : [{ model : User }] });
|
||||
User.findByPrimary( Buffer.from('id'), { include : [{ model : User, as : 'ToDo' }] });
|
||||
User.findByPrimary( Buffer.from('id'), { include : [User, { model : User, as : 'ToDo' }] });
|
||||
|
||||
User.findByPk( 1 );
|
||||
User.findByPk( 1, { attributes : ['id'] } );
|
||||
User.findByPk( 1, { logging : function( ) { } } );
|
||||
User.findByPk( 1, { transaction : t } );
|
||||
User.findByPk( 1, { include : [User] } );
|
||||
User.findByPk( 1, { include : [{ model : User }] });
|
||||
User.findByPk( 1, { include : [{ model : User, as : 'ToDo' }] });
|
||||
User.findByPk( 1, { include : [User, { model : User, as : 'ToDo' }] });
|
||||
User.findByPk( 'id' );
|
||||
User.findByPk( 'id', { attributes : ['id'] } );
|
||||
User.findByPk( 'id', { logging : function( ) { } } );
|
||||
User.findByPk( 'id', { transaction : t } );
|
||||
User.findByPk( 'id', { include : [User] } );
|
||||
User.findByPk( 'id', { include : [{ model : User }] });
|
||||
User.findByPk( 'id', { include : [{ model : User, as : 'ToDo' }] });
|
||||
User.findByPk( 'id', { include : [User, { model : User, as : 'ToDo' }] });
|
||||
User.findByPk( Buffer.from('id') );
|
||||
User.findByPk( Buffer.from('id'), { attributes : ['id'] } );
|
||||
User.findByPk( Buffer.from('id'), { logging : function( ) { } } );
|
||||
User.findByPk( Buffer.from('id'), { transaction : t } );
|
||||
User.findByPk( Buffer.from('id'), { include : [User] } );
|
||||
User.findByPk( Buffer.from('id'), { include : [{ model : User }] });
|
||||
User.findByPk( Buffer.from('id'), { include : [{ model : User, as : 'ToDo' }] });
|
||||
User.findByPk( Buffer.from('id'), { include : [User, { model : User, as : 'ToDo' }] });
|
||||
|
||||
User.findByPk( 'a string' );
|
||||
User.findByPk( 42 );
|
||||
User.findByPk( Buffer.from('a buffer') );
|
||||
|
||||
User.findOne( { where : { username : 'foo' } } );
|
||||
User.findOne( { where : { id : 1 }, attributes : ['id', ['username', 'name']] } );
|
||||
|
||||
Reference in New Issue
Block a user