mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-05 20:02:05 +08:00
Merge pull request #24397 from todd/revert_scope_change
[Sequelize] Fix regression in Model.scope
This commit is contained in:
2
types/sequelize/index.d.ts
vendored
2
types/sequelize/index.d.ts
vendored
@@ -3794,7 +3794,7 @@ declare namespace sequelize {
|
||||
* @return Model A reference to the model, with the scope(s) applied. Calling scope again on the returned
|
||||
* model will clear the previous scope.
|
||||
*/
|
||||
scope(options?: string | ScopeOptions | AnyWhereOptions | Array<string | ScopeOptions | AnyWhereOptions>): Model<TInstance, TAttributes>;
|
||||
scope(options?: string | ScopeOptions | AnyWhereOptions | Array<string | ScopeOptions | AnyWhereOptions>): this;
|
||||
|
||||
/**
|
||||
* Search for multiple instances.
|
||||
|
||||
@@ -10,10 +10,14 @@ import Bluebird = require('bluebird');
|
||||
interface AnyAttributes { [name: string]: boolean | number | string | object; };
|
||||
interface AnyInstance extends Sequelize.Instance<AnyAttributes> { };
|
||||
|
||||
interface UserModel extends Sequelize.Model<AnyInstance, AnyAttributes> {
|
||||
findUser?(arbitraryThing: any): Promise<AnyInstance>;
|
||||
}
|
||||
|
||||
var s = new Sequelize( '' );
|
||||
var sequelize = s;
|
||||
var DataTypes = Sequelize;
|
||||
var User = s.define<AnyInstance, AnyAttributes>( 'user', {} );
|
||||
var User: UserModel = s.define<AnyInstance, AnyAttributes>( 'user', {} );
|
||||
var user = User.build();
|
||||
var Task = s.define<AnyInstance, AnyAttributes>( 'task', {} );
|
||||
var Group = s.define<AnyInstance, AnyAttributes>( 'group', {} );
|
||||
@@ -893,6 +897,7 @@ User.addScope('lowAccessWithParam', function(id: number) {
|
||||
} );
|
||||
|
||||
User.scope( 'lowAccess' ).count();
|
||||
User.scope( 'lowAccess' ).findUser( 'foo' );
|
||||
User.scope( { where : { parent_id : 2 } } );
|
||||
User.scope( [ 'lowAccess', { method: ['lowAccessWithParam', 2] }, { where : { parent_id : 2 } } ] )
|
||||
|
||||
|
||||
Reference in New Issue
Block a user