diff --git a/types/sequelize/index.d.ts b/types/sequelize/index.d.ts index 353f87b3e9..5d65397bf7 100644 --- a/types/sequelize/index.d.ts +++ b/types/sequelize/index.d.ts @@ -3202,21 +3202,21 @@ declare namespace sequelize { } /** - * Shortcut for types used in FindOptions.attributes - */ + * Shortcut for types used in FindOptions.attributes + */ type FindOptionsAttributesArray = Array; /** -* Options that are passed to any model creating a SELECT query -* -* A hash of options to describe the scope of the search -*/ + * Options that are passed to any model creating a SELECT query + * + * A hash of options to describe the scope of the search + */ interface FindOptions extends LoggingOptions, SearchPathOptions { /** * A hash of attributes to describe your search. See above for examples. */ - where?: WhereOptions | fn | Array; + where?: WhereOptions | where | fn | Array; /** * A list of the attributes that you want to select. To rename an attribute, you can pass an array, with diff --git a/types/sequelize/sequelize-tests.ts b/types/sequelize/sequelize-tests.ts index 4ecbb8a1b0..77daabefc9 100644 --- a/types/sequelize/sequelize-tests.ts +++ b/types/sequelize/sequelize-tests.ts @@ -7,7 +7,7 @@ import Bluebird = require('bluebird'); // ~~~~~~~~~~ // -interface AnyAttributes { }; +interface AnyAttributes { [name: string]: boolean | number | string | object; }; interface AnyInstance extends Sequelize.Instance { }; var s = new Sequelize( '' ); @@ -914,6 +914,7 @@ User.findAll( { attributes: [[s.fn('count', Sequelize.col('*')), 'count']], grou User.findAll( { attributes: [s.cast(s.fn('count', Sequelize.col('*')), 'INTEGER')] }); User.findAll( { attributes: [[s.cast(s.fn('count', Sequelize.col('*')), 'INTEGER'), 'count']] }); User.findAll( { where : s.fn('count', [0, 10]) } ); +User.findAll( { where: s.where(s.fn('lower', s.col('email')), s.fn('lower', 'TEST@SEQUELIZEJS.COM')) } ); User.findAll( { subQuery: false, include : [User], order : [[User, User, 'numYears', 'c']] } ); User.findAll( { rejectOnEmpty: true }); @@ -937,6 +938,7 @@ User.findOne( { where : { name : 'Boris' }, include : [User, { model : User, as User.findOne( { where : { username : 'someone' }, include : [User] } ); User.findOne( { where : { username : 'barfooz' }, raw : true } ); User.findOne( { where : s.fn('count', []) } ); +User.findOne( { where: s.where(s.fn('lower', s.col('email')), s.fn('lower', 'TEST@SEQUELIZEJS.COM')) } ); /* NOTE https://github.com/DefinitelyTyped/DefinitelyTyped/pull/5590 User.findOne( { updatedAt : { ne : null } } ); */