[sequelize] add where option to DefineIndexesOptions (#16357)

This commit is contained in:
Evgeny 2017-05-06 02:22:36 +03:00 committed by Mohamed Hegazy
parent da3ab04e72
commit c49e2aa150
2 changed files with 11 additions and 4 deletions

View File

@ -4757,6 +4757,11 @@ declare namespace sequelize {
*/
fields?: Array<string | { attribute: string, length: number, order: string, collate: string }>;
/**
* Condition for partioal index
*/
where?: WhereOptions;
}
/**

View File

@ -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 },