From c49e2aa150ef6c19d2f8e7c0b9ee7b98cb71a229 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 6 May 2017 02:22:36 +0300 Subject: [PATCH] [sequelize] add where option to DefineIndexesOptions (#16357) --- types/sequelize/v3/index.d.ts | 5 +++++ types/sequelize/v3/sequelize-tests.ts | 10 ++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/types/sequelize/v3/index.d.ts b/types/sequelize/v3/index.d.ts index a02ba7d0ed..2f2f973c19 100644 --- a/types/sequelize/v3/index.d.ts +++ b/types/sequelize/v3/index.d.ts @@ -4757,6 +4757,11 @@ declare namespace sequelize { */ fields?: Array; + /** + * Condition for partioal index + */ + where?: WhereOptions; + } /** diff --git a/types/sequelize/v3/sequelize-tests.ts b/types/sequelize/v3/sequelize-tests.ts index 3e972d3119..9f5eac61ad 100644 --- a/types/sequelize/v3/sequelize-tests.ts +++ b/types/sequelize/v3/sequelize-tests.ts @@ -1261,7 +1261,7 @@ s.define( 'UserWithUniqueUsername', { username : { type : Sequelize.STRING, unique : { name : 'user_and_email', msg : 'User and email must be unique' } }, email : { type : Sequelize.STRING, unique : 'user_and_email' } } ); -/* NOTE https://github.com/DefinitelyTyped/DefinitelyTyped/pull/5590 + s.define( 'UserWithUniqueUsername', { user_id : { type : Sequelize.INTEGER }, email : { type : Sequelize.STRING } @@ -1269,13 +1269,15 @@ s.define( 'UserWithUniqueUsername', { indexes : [ { name : 'user_and_email_index', - msg : 'User and email must be unique', unique : true, method : 'BTREE', - fields : ['user_id', { attribute : 'email', collate : 'en_US', order : 'DESC', length : 5 }] + fields : ['user_id', { attribute : 'email', collate : 'en_US', order : 'DESC', length : 5 }], + where : { + user_id : { $not: null } + } }] } ); - */ + s.define( 'TaskBuild', { title : { type : Sequelize.STRING, defaultValue : 'a task!' }, foo : { type : Sequelize.INTEGER, defaultValue : 2 },