Changing 'scope' definition (#14810)

current definition
```ts
scope(options?: string | string[] | ScopeOptions | WhereOptions): this;
```
doesn't allow are valid calls. example from [documentation](http://docs.sequelizejs.com/en/latest/docs/scopes/):
```ts
Project.scope('random', { method: ['accessLevel', 19]}).findAll();
```
changing it to
```ts
scope(options?: string | ScopeOptions | WhereOptions | Array<string|ScopeOptions|WhereOptions>): this;
```
should fix the issue since, according to the docs
```ts
// These two are equivalent
Project.scope('deleted', 'activeUsers').findAll();
Project.scope(['deleted', 'activeUsers']).findAll();
```
This commit is contained in:
Aleksandar Rodić
2017-03-11 00:09:55 +01:00
committed by Mohamed Hegazy
parent 12b1792ca0
commit 75ffb8e47d
4 changed files with 10 additions and 4 deletions

View File

@@ -3671,7 +3671,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 | string[] | ScopeOptions | WhereOptions): this;
scope(options?: string | ScopeOptions | WhereOptions | Array<string | ScopeOptions | WhereOptions>): this;
/**
* Search for multiple instances.

View File

@@ -853,11 +853,14 @@ User.schema( 'special' ).create( { age : 3 }, { logging : function( ) {} } );
User.getTableName();
User.addScope('lowAccess', { where : { parent_id : 2 } });
User.addScope('lowAccess', function() { } );
User.addScope('lowAccess', { where : { parent_id : 2 } }, { override: true });
User.addScope('lowAccessWithParam', function(id: number) {
return { where : { parent_id : id } }
} );
User.scope( 'lowAccess' ).count();
User.scope( { where : { parent_id : 2 } } );
User.scope( [ 'lowAccess', { method: ['lowAccessWithParam', 2] }, { where : { parent_id : 2 } } ] )
User.findAll();
User.findAll( { where : { data : { employment : null } } } );

View File

@@ -3648,7 +3648,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 | string[] | ScopeOptions | WhereOptions): this;
scope(options?: string | ScopeOptions | WhereOptions | Array<string | ScopeOptions | WhereOptions>): this;
/**
* Search for multiple instances.

View File

@@ -840,11 +840,14 @@ User.schema( 'special' ).create( { age : 3 }, { logging : function( ) {} } );
User.getTableName();
User.addScope('lowAccess', { where : { parent_id : 2 } });
User.addScope('lowAccess', function() { } );
User.addScope('lowAccess', { where : { parent_id : 2 } }, { override: true });
User.addScope('lowAccessWithParam', function(id: number) {
return { where : { parent_id : id } }
} );
User.scope( 'lowAccess' ).count();
User.scope( { where : { parent_id : 2 } } );
User.scope( [ 'lowAccess', { method: ['lowAccessWithParam', 2] }, { where : { parent_id : 2 } } ] )
User.findAll();
User.findAll( { where : { data : { employment : null } } } );