Skip to content

Commit

Permalink
🤖 Merge PR DefinitelyTyped#59700 sequelize v4: allow non-array includ…
Browse files Browse the repository at this point in the history
…e options by @jokester

* sequelize v4: allow non-array include options

* sequelize v4: add tests
  • Loading branch information
jokester authored Apr 25, 2022
1 parent 44fca2b commit b2d66e0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 3 additions & 3 deletions types/sequelize/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3292,7 +3292,7 @@ declare namespace sequelize {
/**
* Load further nested related models
*/
include?: Array<Model<any, any> | IncludeOptions> | undefined;
include?: Array<Model<any, any> | IncludeOptions> | Model<any, any> | IncludeOptions | undefined;

/**
* If true, only non-deleted records will be returned. If false, both deleted and non-deleted records will
Expand Down Expand Up @@ -3355,7 +3355,7 @@ declare namespace sequelize {
* If your association are set up with an `as` (eg. `X.hasMany(Y, { as: 'Z }`, you need to specify Z in
* the as attribute when eager loading Y).
*/
include?: Array<Model<any, any> | IncludeOptions> | undefined;
include?: Array<Model<any, any> | IncludeOptions> | Model<any, any> | IncludeOptions | undefined;

/**
* Specifies an ordering. If a string is provided, it will be escaped. Using an array, you can provide
Expand Down Expand Up @@ -3436,7 +3436,7 @@ declare namespace sequelize {
/**
* Include options. See `find` for details
*/
include?: Array<Model<any, any> | IncludeOptions> | undefined;
include?: Array<Model<any, any> | IncludeOptions> | Model<any, any> | IncludeOptions | undefined;

/**
* Apply column on which COUNT() should be applied
Expand Down
2 changes: 2 additions & 0 deletions types/sequelize/sequelize-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,7 @@ User.findAll( {
} );
User.findAll( { paranoid : false, where : [' IS NOT NULL '], include : [{ model : User }] } );
User.findAll( { include : [{ model : Task, paranoid: false }] } );
User.findAll( { include : { model : Task, include: Task, paranoid: false } } );
User.findAll( { transaction : t } );
User.findAll( { where : { data : { name : { last : 's' }, employment : { $ne : 'a' } } }, order : [['id', 'ASC']] } );
User.findAll( { where : { username : ['boo', 'boo2'] } } );
Expand Down Expand Up @@ -1113,6 +1114,7 @@ User.count( { transaction : t } );
User.count().then( function( c ) { c.toFixed(); } );
User.count( { where : ["username LIKE '%us%'"] } );
User.count( { include : [{ model : User, required : false }] } );
User.count( { include : User } );
User.count( { distinct : true, include : [{ model : User, required : false }] } );
User.count( { attributes : ['data'], group : ['data'] } );
User.count( { where : { access_level : { gt : 5 } } } );
Expand Down

0 comments on commit b2d66e0

Please sign in to comment.