Merge pull request #24397 from todd/revert_scope_change

[Sequelize] Fix regression in Model.scope
This commit is contained in:
Mine Starks
2018-03-23 14:29:48 -07:00
committed by GitHub
2 changed files with 7 additions and 2 deletions

View File

@@ -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.

View File

@@ -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 } } ] )