add missing constructor options (database, username, password, retry, typeValidation [only v4]), add RetryOptions interface for reuse and DRY purpose (#18896)

This commit is contained in:
kukoo1
2017-08-14 11:22:49 -07:00
committed by Mohamed Hegazy
parent 1e9a61cce4
commit bf2e0faa52
4 changed files with 140 additions and 3 deletions
+67 -2
View File
@@ -1,6 +1,10 @@
// Type definitions for Sequelize 4.0.0
// Project: http://sequelizejs.com
// Definitions by: samuelneff <https://github.com/samuelneff>, Peter Harris <https://github.com/codeanimal>, Ivan Drinchev <https://github.com/drinchev>, Brendan Abolivier <https://github.com/babolivier>
// Definitions by: samuelneff <https://github.com/samuelneff>
// Peter Harris <https://github.com/codeanimal>
// Ivan Drinchev <https://github.com/drinchev>
// Brendan Abolivier <https://github.com/babolivier>
// Patsakol Tangjitcharoenchai <https://github.com/kukoo1>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
@@ -4613,7 +4617,7 @@ declare namespace sequelize {
/**
* Set of flags that control when a query is automatically retried.
*/
retry?: { match?: string[], max?: number };
retry?: RetryOptions;
/**
* If false do not prepend the query with the search_path (Postgres only)
@@ -5205,6 +5209,25 @@ declare namespace sequelize {
}
/**
* Interface for retry Options in the sequelize constructor and QueryOptions
*
* @see Options, QueryOptions
*/
interface RetryOptions {
/**
* Only retry a query if the error matches one of these strings.
*/
match?: string[];
/**
* How many times a failing query is automatically retried. Set to 0 to disable retrying on SQL_BUSY error.
*/
max?: number
}
/**
* Options for the constructor of Sequelize main class
*/
@@ -5254,6 +5277,21 @@ declare namespace sequelize {
*/
protocol?: string;
/**
* The username which is used to authenticate against the database.
*/
username?: string;
/**
* The password which is used to authenticate against the database.
*/
password?: string;
/**
* The name of the database
*/
database?: string;
/**
* Default options for model definitions. See sequelize.define for options
*/
@@ -5317,6 +5355,19 @@ declare namespace sequelize {
*/
replication?: ReplicationOptions;
/**
* Set of flags that control when a query is automatically retried.
*/
retry?: RetryOptions;
/**
* Run built in type validators on insert and update,
* e.g. validate that arguments passed to integer fields are integer-like.
*
* Defaults to false
*/
typeValidation?: boolean;
/**
* Connection pool options
*/
@@ -5541,6 +5592,15 @@ declare namespace sequelize {
*/
new (uri: string, options?: Options): Sequelize;
/**
* Instantiate sequelize with an options object which containing username, password, database
* @name Sequelize
* @constructor
*
* @param options An object with options. See above for possible options
*/
new (options: Options): Sequelize;
/**
* Provide access to continuation-local-storage (http://docs.sequelizejs.com/en/latest/api/sequelize/#transactionoptions-promise)
*/
@@ -5577,6 +5637,11 @@ declare namespace sequelize {
*/
models: ModelsHashInterface;
/**
* Defined options.
*/
options: Options;
/**
* Returns the specified dialect.
*/
+10
View File
@@ -1193,6 +1193,16 @@ new Sequelize( 'sequelize', null, null, {
}
}
} );
new Sequelize( {
database: 'db',
username: 'user',
password: 'pass',
retry: {
match: ['failed'],
max: 3
},
typeValidation: true
} );
s.model( 'Project' );
s.models['Project'];
+54 -1
View File
@@ -4509,7 +4509,7 @@ declare namespace sequelize {
/**
* Set of flags that control when a query is automatically retried.
*/
retry?: { match?: string[], max?: number };
retry?: RetryOptions;
/**
* If false do not prepend the query with the search_path (Postgres only)
@@ -5069,6 +5069,25 @@ declare namespace sequelize {
}
/**
* Interface for retry Options in the sequelize constructor and QueryOptions
*
* @see Options, QueryOptions
*/
interface RetryOptions {
/**
* Only retry a query if the error matches one of these strings.
*/
match?: string[];
/**
* How many times a failing query is automatically retried. Set to 0 to disable retrying on SQL_BUSY error.
*/
max?: number
}
/**
* Options for the constructor of Sequelize main class
*/
@@ -5118,6 +5137,21 @@ declare namespace sequelize {
*/
protocol?: string;
/**
* The username which is used to authenticate against the database.
*/
username?: string;
/**
* The password which is used to authenticate against the database.
*/
password?: string;
/**
* The name of the database
*/
database?: string;
/**
* Default options for model definitions. See sequelize.define for options
*/
@@ -5181,6 +5215,11 @@ declare namespace sequelize {
*/
replication?: ReplicationOptions;
/**
* Set of flags that control when a query is automatically retried.
*/
retry?: RetryOptions;
/**
* Connection pool options
*/
@@ -5405,6 +5444,15 @@ declare namespace sequelize {
*/
new (uri: string, options?: Options): Sequelize;
/**
* Instantiate sequelize with an options object which containing username, password, database
* @name Sequelize
* @constructor
*
* @param options An object with options. See above for possible options
*/
new (options: Options): Sequelize;
/**
* Provide access to continuation-local-storage (http://docs.sequelizejs.com/en/latest/api/sequelize/#transactionoptions-promise)
*/
@@ -5441,6 +5489,11 @@ declare namespace sequelize {
*/
models: ModelsHashInterface;
/**
* Defined options.
*/
options: Options;
/**
* Returns the specified dialect.
*/
+9
View File
@@ -1170,6 +1170,15 @@ new Sequelize( 'sequelize', null, null, {
}
}
} );
new Sequelize( {
database: 'db',
username: 'user',
password: 'pass',
retry: {
match: ['failed'],
max: 3
}
} );
s.model( 'Project' );
s.models['Project'];