From 3ec3169f642ef2970422bf38298c11cd8eaaf33e Mon Sep 17 00:00:00 2001 From: James O'Cull Date: Thu, 3 Dec 2015 09:55:13 -0500 Subject: [PATCH 1/4] Commit / Rollback on Transaction interface should return promise --- sequelize/sequelize.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sequelize/sequelize.d.ts b/sequelize/sequelize.d.ts index 9b5e935bff..46a0ba41a0 100644 --- a/sequelize/sequelize.d.ts +++ b/sequelize/sequelize.d.ts @@ -5706,12 +5706,12 @@ declare module "sequelize" { /** * Commit the transaction */ - commit() : Transaction; + commit() : Promise; /** * Rollback (abort) the transaction */ - rollback() : Transaction; + rollback() : Promise; } From 5ff03e2f4153ba30e5418e7dcd6200fa81a108b6 Mon Sep 17 00:00:00 2001 From: James O'Cull Date: Thu, 3 Dec 2015 14:30:10 -0500 Subject: [PATCH 2/4] Changes to unify transaction support across various interfaces, especially association mixins --- sequelize/sequelize.d.ts | 166 ++++++++++++++------------------------- 1 file changed, 58 insertions(+), 108 deletions(-) diff --git a/sequelize/sequelize.d.ts b/sequelize/sequelize.d.ts index 46a0ba41a0..74f682e27e 100644 --- a/sequelize/sequelize.d.ts +++ b/sequelize/sequelize.d.ts @@ -19,13 +19,12 @@ declare module "sequelize" { // // https://github.com/sequelize/sequelize/tree/v3.4.1/lib/associations // - - + /** * The options for the getAssociation mixin of the belongsTo association. * @see BelongsToGetAssociationMixin */ - interface BelongsToGetAssociationMixinOptions { + interface BelongsToGetAssociationMixinOptions extends Transactable { /** * Apply a scope on the related model, or remove its default scope by passing false. */ @@ -62,7 +61,7 @@ declare module "sequelize" { * The options for the setAssociation mixin of the belongsTo association. * @see BelongsToSetAssociationMixin */ - interface BelongsToSetAssociationMixinOptions { + interface BelongsToSetAssociationMixinOptions extends Transactable { /** * Skip saving this after setting the foreign key if false. */ @@ -103,7 +102,7 @@ declare module "sequelize" { * The options for the createAssociation mixin of the belongsTo association. * @see BelongsToCreateAssociationMixin */ - interface BelongsToCreateAssociationMixinOptions { } + interface BelongsToCreateAssociationMixinOptions extends Transactable { } /** * The createAssociation mixin applied to models with belongsTo. @@ -139,7 +138,7 @@ declare module "sequelize" { * The options for the getAssociation mixin of the hasOne association. * @see HasOneGetAssociationMixin */ - interface HasOneGetAssociationMixinOptions { + interface HasOneGetAssociationMixinOptions extends Transactable { /** * Apply a scope on the related model, or remove its default scope by passing false. */ @@ -176,7 +175,7 @@ declare module "sequelize" { * The options for the setAssociation mixin of the hasOne association. * @see HasOneSetAssociationMixin */ - interface HasOneSetAssociationMixinOptions { + interface HasOneSetAssociationMixinOptions extends Transactable { /** * Skip saving this after setting the foreign key if false. */ @@ -217,7 +216,7 @@ declare module "sequelize" { * The options for the createAssociation mixin of the hasOne association. * @see HasOneCreateAssociationMixin */ - interface HasOneCreateAssociationMixinOptions { } + interface HasOneCreateAssociationMixinOptions extends Transactable { } /** * The createAssociation mixin applied to models with hasOne. @@ -253,7 +252,7 @@ declare module "sequelize" { * The options for the getAssociations mixin of the hasMany association. * @see HasManyGetAssociationsMixin */ - interface HasManyGetAssociationsMixinOptions { + interface HasManyGetAssociationsMixinOptions extends Transactable { /** * An optional where clause to limit the associated models. @@ -303,7 +302,7 @@ declare module "sequelize" { * The options for the setAssociations mixin of the hasMany association. * @see HasManySetAssociationsMixin */ - interface HasManySetAssociationsMixinOptions { + interface HasManySetAssociationsMixinOptions extends Transactable { /** * Run validation for the join model. @@ -353,7 +352,7 @@ declare module "sequelize" { * The options for the addAssociations mixin of the hasMany association. * @see HasManyAddAssociationsMixin */ - interface HasManyAddAssociationsMixinOptions { + interface HasManyAddAssociationsMixinOptions extends Transactable { /** * Run validation for the join model. @@ -402,7 +401,7 @@ declare module "sequelize" { * The options for the addAssociation mixin of the hasMany association. * @see HasManyAddAssociationMixin */ - interface HasManyAddAssociationMixinOptions { + interface HasManyAddAssociationMixinOptions extends Transactable { /** * Run validation for the join model. @@ -451,7 +450,7 @@ declare module "sequelize" { * The options for the createAssociation mixin of the hasMany association. * @see HasManyCreateAssociationMixin */ - interface HasManyCreateAssociationMixinOptions { } + interface HasManyCreateAssociationMixinOptions extends Transactable { } /** * The createAssociation mixin applied to models with hasMany. @@ -494,7 +493,7 @@ declare module "sequelize" { * The options for the removeAssociation mixin of the hasMany association. * @see HasManyRemoveAssociationMixin */ - interface HasManyRemoveAssociationMixinOptions { } + interface HasManyRemoveAssociationMixinOptions extends Transactable { } /** * The removeAssociation mixin applied to models with hasMany. @@ -537,7 +536,7 @@ declare module "sequelize" { * The options for the removeAssociations mixin of the hasMany association. * @see HasManyRemoveAssociationsMixin */ - interface HasManyRemoveAssociationsMixinOptions { } + interface HasManyRemoveAssociationsMixinOptions extends Transactable { } /** * The removeAssociations mixin applied to models with hasMany. @@ -580,7 +579,7 @@ declare module "sequelize" { * The options for the hasAssociation mixin of the hasMany association. * @see HasManyHasAssociationMixin */ - interface HasManyHasAssociationMixinOptions { } + interface HasManyHasAssociationMixinOptions extends Transactable { } /** * The hasAssociation mixin applied to models with hasMany. @@ -623,7 +622,7 @@ declare module "sequelize" { * The options for the hasAssociations mixin of the hasMany association. * @see HasManyHasAssociationsMixin */ - interface HasManyHasAssociationsMixinOptions { } + interface HasManyHasAssociationsMixinOptions extends Transactable { } /** * The removeAssociations mixin applied to models with hasMany. @@ -666,7 +665,7 @@ declare module "sequelize" { * The options for the countAssociations mixin of the hasMany association. * @see HasManyCountAssociationsMixin */ - interface HasManyCountAssociationsMixinOptions { + interface HasManyCountAssociationsMixinOptions extends Transactable { /** * An optional where clause to limit the associated models. @@ -716,7 +715,7 @@ declare module "sequelize" { * The options for the getAssociations mixin of the belongsToMany association. * @see BelongsToManyGetAssociationsMixin */ - interface BelongsToManyGetAssociationsMixinOptions { + interface BelongsToManyGetAssociationsMixinOptions extends Transactable { /** * An optional where clause to limit the associated models. @@ -766,7 +765,7 @@ declare module "sequelize" { * The options for the setAssociations mixin of the belongsToMany association. * @see BelongsToManySetAssociationsMixin */ - interface BelongsToManySetAssociationsMixinOptions { + interface BelongsToManySetAssociationsMixinOptions extends Transactable { /** * Run validation for the join model. @@ -816,7 +815,7 @@ declare module "sequelize" { * The options for the addAssociations mixin of the belongsToMany association. * @see BelongsToManyAddAssociationsMixin */ - interface BelongsToManyAddAssociationsMixinOptions { + interface BelongsToManyAddAssociationsMixinOptions extends Transactable { /** * Run validation for the join model. @@ -865,7 +864,7 @@ declare module "sequelize" { * The options for the addAssociation mixin of the belongsToMany association. * @see BelongsToManyAddAssociationMixin */ - interface BelongsToManyAddAssociationMixinOptions { + interface BelongsToManyAddAssociationMixinOptions extends Transactable { /** * Run validation for the join model. @@ -914,7 +913,7 @@ declare module "sequelize" { * The options for the createAssociation mixin of the belongsToMany association. * @see BelongsToManyCreateAssociationMixin */ - interface BelongsToManyCreateAssociationMixinOptions { } + interface BelongsToManyCreateAssociationMixinOptions extends Transactable { } /** * The createAssociation mixin applied to models with belongsToMany. @@ -957,7 +956,7 @@ declare module "sequelize" { * The options for the removeAssociation mixin of the belongsToMany association. * @see BelongsToManyRemoveAssociationMixin */ - interface BelongsToManyRemoveAssociationMixinOptions { } + interface BelongsToManyRemoveAssociationMixinOptions extends Transactable { } /** * The removeAssociation mixin applied to models with belongsToMany. @@ -1000,7 +999,7 @@ declare module "sequelize" { * The options for the removeAssociations mixin of the belongsToMany association. * @see BelongsToManyRemoveAssociationsMixin */ - interface BelongsToManyRemoveAssociationsMixinOptions { } + interface BelongsToManyRemoveAssociationsMixinOptions extends Transactable { } /** * The removeAssociations mixin applied to models with belongsToMany. @@ -1043,7 +1042,7 @@ declare module "sequelize" { * The options for the hasAssociation mixin of the belongsToMany association. * @see BelongsToManyHasAssociationMixin */ - interface BelongsToManyHasAssociationMixinOptions { } + interface BelongsToManyHasAssociationMixinOptions extends Transactable { } /** * The hasAssociation mixin applied to models with belongsToMany. @@ -1086,7 +1085,7 @@ declare module "sequelize" { * The options for the hasAssociations mixin of the belongsToMany association. * @see BelongsToManyHasAssociationsMixin */ - interface BelongsToManyHasAssociationsMixinOptions { } + interface BelongsToManyHasAssociationsMixinOptions extends Transactable { } /** * The removeAssociations mixin applied to models with belongsToMany. @@ -1129,7 +1128,7 @@ declare module "sequelize" { * The options for the countAssociations mixin of the belongsToMany association. * @see BelongsToManyCountAssociationsMixin */ - interface BelongsToManyCountAssociationsMixinOptions { + interface BelongsToManyCountAssociationsMixinOptions extends Transactable { /** * An optional where clause to limit the associated models. @@ -2538,7 +2537,7 @@ declare module "sequelize" { /** * Options used for Instance.increment method */ - interface InstanceIncrementDecrementOptions { + interface InstanceIncrementDecrementOptions extends Transactable { /** * The number to increment by @@ -2552,39 +2551,29 @@ declare module "sequelize" { */ logging? : boolean | Function; - /** - * Transaction to run query under - */ - transaction? : Transaction; - /** * A hash of attributes to describe your search. See above for examples. */ where? : WhereOptions | Array; - + } /** * Options used for Instance.restore method */ - interface InstanceRestoreOptions { + interface InstanceRestoreOptions extends Transactable { /** * A function that gets executed while running the query to log the sql. */ logging? : boolean | Function; - - /** - * Transaction to run query under - */ - transaction? : Transaction; - + } /** * Options used for Instance.destroy method */ - interface InstanceDestroyOptions { + interface InstanceDestroyOptions extends Transactable { /** * If set to true, paranoid models will actually be deleted @@ -2595,12 +2584,7 @@ declare module "sequelize" { * A function that gets executed while running the query to log the sql. */ logging? : boolean | Function; - - /** - * Transaction to run the query in - */ - transaction? : Transaction; - + } /** @@ -2635,7 +2619,7 @@ declare module "sequelize" { /** * Options used for Instance.save method */ - interface InstanceSaveOptions { + interface InstanceSaveOptions extends Transactable { /** * An optional array of strings, representing database columns. If fields is provided, only those columns @@ -2661,12 +2645,7 @@ declare module "sequelize" { * A function that gets executed while running the query to log the sql. */ logging? : boolean | Function; - - /** - * Transaction to run the query in - */ - transaction? : Transaction; - + } /** @@ -3091,7 +3070,7 @@ declare module "sequelize" { * * A hash of options to describe the scope of the search */ - interface FindOptions { + interface FindOptions extends Transactable { /** * A hash of attributes to describe your search. See above for examples. @@ -3138,11 +3117,6 @@ declare module "sequelize" { */ offset?: number; - /** - * Transaction to run query under - */ - transaction? : Transaction; - /** * Lock the selected rows. Possible options are transaction.LOCK.UPDATE and transaction.LOCK.SHARE. * Postgres also supports transaction.LOCK.KEY_SHARE, transaction.LOCK.NO_KEY_UPDATE and specific model @@ -3170,7 +3144,7 @@ declare module "sequelize" { /** * Options for Model.count method */ - interface CountOptions { + interface CountOptions extends Transactable { /** * A hash of search attributes. @@ -3203,8 +3177,7 @@ declare module "sequelize" { * A function that gets executed while running the query to log the sql. */ logging? : boolean | Function; - - transaction?: Transaction; + } /** @@ -3234,7 +3207,7 @@ declare module "sequelize" { /** * Options for Model.create method */ - interface CreateOptions extends BuildOptions { + interface CreateOptions extends BuildOptions, Transactable { /** * If set, only columns matching those in fields will be saved @@ -3246,11 +3219,6 @@ declare module "sequelize" { */ onDuplicate? : string; - /** - * Transaction to run query under - */ - transaction? : Transaction; - /** * A function that gets executed while running the query to log the sql. */ @@ -3259,12 +3227,13 @@ declare module "sequelize" { silent? : boolean; returning? : boolean; + } /** * Options for Model.findOrInitialize method */ - interface FindOrInitializeOptions { + interface FindOrInitializeOptions extends Transactable { /** * A hash of search attributes. @@ -3276,11 +3245,6 @@ declare module "sequelize" { */ defaults? : TAttributes; - /** - * Transaction to run query under - */ - transaction? : Transaction; - /** * A function that gets executed while running the query to log the sql. */ @@ -3313,7 +3277,7 @@ declare module "sequelize" { /** * Options for Model.bulkCreate method */ - interface BulkCreateOptions { + interface BulkCreateOptions extends Transactable { /** * Fields to insert (defaults to all fields) @@ -3350,11 +3314,6 @@ declare module "sequelize" { */ updateOnDuplicate? : Array; - /** - * Transaction to run query under - */ - transaction? : Transaction; - /** * A function that gets executed while running the query to log the sql. */ @@ -3365,12 +3324,7 @@ declare module "sequelize" { /** * The options passed to Model.destroy in addition to truncate */ - interface TruncateOptions { - - /** - * Transaction to run query under - */ - transaction? : Transaction; + interface TruncateOptions extends Transactable { /** * Only used in conjuction with TRUNCATE. Truncates all tables that have foreign-key references to the @@ -3429,7 +3383,7 @@ declare module "sequelize" { /** * Options for Model.restore */ - interface RestoreOptions { + interface RestoreOptions extends Transactable { /** * Filter the restore @@ -3457,17 +3411,12 @@ declare module "sequelize" { */ logging? : boolean | Function; - /** - * Transaction to run query under - */ - transaction? : Transaction; - } /** * Options used for Model.update */ - interface UpdateOptions { + interface UpdateOptions extends Transactable { /** * Options to describe the scope of the search. @@ -3524,11 +3473,6 @@ declare module "sequelize" { */ logging? : boolean | Function; - /** - * Transaction to run query under - */ - transaction? : Transaction; - } /** @@ -4422,7 +4366,7 @@ declare module "sequelize" { * * @see Options */ - interface QueryOptions { + interface QueryOptions extends Transactable { /** * If true, sequelize will not try to format the results of the query, or build an instance of a model from @@ -4430,11 +4374,6 @@ declare module "sequelize" { */ raw?: boolean; - /** - * The transaction that the query should be executed under - */ - transaction?: Transaction; - /** * The type of query you are executing. The query type affects how results are formatted before they are * passed back. The type is a string, but `Sequelize.QueryTypes` is provided as convenience shortcuts. @@ -5838,7 +5777,18 @@ declare module "sequelize" { * A function that gets executed while running the query to log the sql. */ logging?: Function; - + } + + /** + * An interface that allows an item to support working under a transaction + * + * @param transaction Transaction The optional transaction to run under + */ + interface Transactable { + /** + * Transaction to run query under + */ + transaction?: Transaction; } // From 2e5439d881f3e744175633c21c26a656fbc66763 Mon Sep 17 00:00:00 2001 From: James O'Cull Date: Thu, 3 Dec 2015 17:29:21 -0500 Subject: [PATCH 3/4] Revert "Changes to unify transaction support across various interfaces, especially association mixins" This reverts commit 5ff03e2f4153ba30e5418e7dcd6200fa81a108b6. --- sequelize/sequelize.d.ts | 166 +++++++++++++++++++++++++-------------- 1 file changed, 108 insertions(+), 58 deletions(-) diff --git a/sequelize/sequelize.d.ts b/sequelize/sequelize.d.ts index 74f682e27e..46a0ba41a0 100644 --- a/sequelize/sequelize.d.ts +++ b/sequelize/sequelize.d.ts @@ -19,12 +19,13 @@ declare module "sequelize" { // // https://github.com/sequelize/sequelize/tree/v3.4.1/lib/associations // - + + /** * The options for the getAssociation mixin of the belongsTo association. * @see BelongsToGetAssociationMixin */ - interface BelongsToGetAssociationMixinOptions extends Transactable { + interface BelongsToGetAssociationMixinOptions { /** * Apply a scope on the related model, or remove its default scope by passing false. */ @@ -61,7 +62,7 @@ declare module "sequelize" { * The options for the setAssociation mixin of the belongsTo association. * @see BelongsToSetAssociationMixin */ - interface BelongsToSetAssociationMixinOptions extends Transactable { + interface BelongsToSetAssociationMixinOptions { /** * Skip saving this after setting the foreign key if false. */ @@ -102,7 +103,7 @@ declare module "sequelize" { * The options for the createAssociation mixin of the belongsTo association. * @see BelongsToCreateAssociationMixin */ - interface BelongsToCreateAssociationMixinOptions extends Transactable { } + interface BelongsToCreateAssociationMixinOptions { } /** * The createAssociation mixin applied to models with belongsTo. @@ -138,7 +139,7 @@ declare module "sequelize" { * The options for the getAssociation mixin of the hasOne association. * @see HasOneGetAssociationMixin */ - interface HasOneGetAssociationMixinOptions extends Transactable { + interface HasOneGetAssociationMixinOptions { /** * Apply a scope on the related model, or remove its default scope by passing false. */ @@ -175,7 +176,7 @@ declare module "sequelize" { * The options for the setAssociation mixin of the hasOne association. * @see HasOneSetAssociationMixin */ - interface HasOneSetAssociationMixinOptions extends Transactable { + interface HasOneSetAssociationMixinOptions { /** * Skip saving this after setting the foreign key if false. */ @@ -216,7 +217,7 @@ declare module "sequelize" { * The options for the createAssociation mixin of the hasOne association. * @see HasOneCreateAssociationMixin */ - interface HasOneCreateAssociationMixinOptions extends Transactable { } + interface HasOneCreateAssociationMixinOptions { } /** * The createAssociation mixin applied to models with hasOne. @@ -252,7 +253,7 @@ declare module "sequelize" { * The options for the getAssociations mixin of the hasMany association. * @see HasManyGetAssociationsMixin */ - interface HasManyGetAssociationsMixinOptions extends Transactable { + interface HasManyGetAssociationsMixinOptions { /** * An optional where clause to limit the associated models. @@ -302,7 +303,7 @@ declare module "sequelize" { * The options for the setAssociations mixin of the hasMany association. * @see HasManySetAssociationsMixin */ - interface HasManySetAssociationsMixinOptions extends Transactable { + interface HasManySetAssociationsMixinOptions { /** * Run validation for the join model. @@ -352,7 +353,7 @@ declare module "sequelize" { * The options for the addAssociations mixin of the hasMany association. * @see HasManyAddAssociationsMixin */ - interface HasManyAddAssociationsMixinOptions extends Transactable { + interface HasManyAddAssociationsMixinOptions { /** * Run validation for the join model. @@ -401,7 +402,7 @@ declare module "sequelize" { * The options for the addAssociation mixin of the hasMany association. * @see HasManyAddAssociationMixin */ - interface HasManyAddAssociationMixinOptions extends Transactable { + interface HasManyAddAssociationMixinOptions { /** * Run validation for the join model. @@ -450,7 +451,7 @@ declare module "sequelize" { * The options for the createAssociation mixin of the hasMany association. * @see HasManyCreateAssociationMixin */ - interface HasManyCreateAssociationMixinOptions extends Transactable { } + interface HasManyCreateAssociationMixinOptions { } /** * The createAssociation mixin applied to models with hasMany. @@ -493,7 +494,7 @@ declare module "sequelize" { * The options for the removeAssociation mixin of the hasMany association. * @see HasManyRemoveAssociationMixin */ - interface HasManyRemoveAssociationMixinOptions extends Transactable { } + interface HasManyRemoveAssociationMixinOptions { } /** * The removeAssociation mixin applied to models with hasMany. @@ -536,7 +537,7 @@ declare module "sequelize" { * The options for the removeAssociations mixin of the hasMany association. * @see HasManyRemoveAssociationsMixin */ - interface HasManyRemoveAssociationsMixinOptions extends Transactable { } + interface HasManyRemoveAssociationsMixinOptions { } /** * The removeAssociations mixin applied to models with hasMany. @@ -579,7 +580,7 @@ declare module "sequelize" { * The options for the hasAssociation mixin of the hasMany association. * @see HasManyHasAssociationMixin */ - interface HasManyHasAssociationMixinOptions extends Transactable { } + interface HasManyHasAssociationMixinOptions { } /** * The hasAssociation mixin applied to models with hasMany. @@ -622,7 +623,7 @@ declare module "sequelize" { * The options for the hasAssociations mixin of the hasMany association. * @see HasManyHasAssociationsMixin */ - interface HasManyHasAssociationsMixinOptions extends Transactable { } + interface HasManyHasAssociationsMixinOptions { } /** * The removeAssociations mixin applied to models with hasMany. @@ -665,7 +666,7 @@ declare module "sequelize" { * The options for the countAssociations mixin of the hasMany association. * @see HasManyCountAssociationsMixin */ - interface HasManyCountAssociationsMixinOptions extends Transactable { + interface HasManyCountAssociationsMixinOptions { /** * An optional where clause to limit the associated models. @@ -715,7 +716,7 @@ declare module "sequelize" { * The options for the getAssociations mixin of the belongsToMany association. * @see BelongsToManyGetAssociationsMixin */ - interface BelongsToManyGetAssociationsMixinOptions extends Transactable { + interface BelongsToManyGetAssociationsMixinOptions { /** * An optional where clause to limit the associated models. @@ -765,7 +766,7 @@ declare module "sequelize" { * The options for the setAssociations mixin of the belongsToMany association. * @see BelongsToManySetAssociationsMixin */ - interface BelongsToManySetAssociationsMixinOptions extends Transactable { + interface BelongsToManySetAssociationsMixinOptions { /** * Run validation for the join model. @@ -815,7 +816,7 @@ declare module "sequelize" { * The options for the addAssociations mixin of the belongsToMany association. * @see BelongsToManyAddAssociationsMixin */ - interface BelongsToManyAddAssociationsMixinOptions extends Transactable { + interface BelongsToManyAddAssociationsMixinOptions { /** * Run validation for the join model. @@ -864,7 +865,7 @@ declare module "sequelize" { * The options for the addAssociation mixin of the belongsToMany association. * @see BelongsToManyAddAssociationMixin */ - interface BelongsToManyAddAssociationMixinOptions extends Transactable { + interface BelongsToManyAddAssociationMixinOptions { /** * Run validation for the join model. @@ -913,7 +914,7 @@ declare module "sequelize" { * The options for the createAssociation mixin of the belongsToMany association. * @see BelongsToManyCreateAssociationMixin */ - interface BelongsToManyCreateAssociationMixinOptions extends Transactable { } + interface BelongsToManyCreateAssociationMixinOptions { } /** * The createAssociation mixin applied to models with belongsToMany. @@ -956,7 +957,7 @@ declare module "sequelize" { * The options for the removeAssociation mixin of the belongsToMany association. * @see BelongsToManyRemoveAssociationMixin */ - interface BelongsToManyRemoveAssociationMixinOptions extends Transactable { } + interface BelongsToManyRemoveAssociationMixinOptions { } /** * The removeAssociation mixin applied to models with belongsToMany. @@ -999,7 +1000,7 @@ declare module "sequelize" { * The options for the removeAssociations mixin of the belongsToMany association. * @see BelongsToManyRemoveAssociationsMixin */ - interface BelongsToManyRemoveAssociationsMixinOptions extends Transactable { } + interface BelongsToManyRemoveAssociationsMixinOptions { } /** * The removeAssociations mixin applied to models with belongsToMany. @@ -1042,7 +1043,7 @@ declare module "sequelize" { * The options for the hasAssociation mixin of the belongsToMany association. * @see BelongsToManyHasAssociationMixin */ - interface BelongsToManyHasAssociationMixinOptions extends Transactable { } + interface BelongsToManyHasAssociationMixinOptions { } /** * The hasAssociation mixin applied to models with belongsToMany. @@ -1085,7 +1086,7 @@ declare module "sequelize" { * The options for the hasAssociations mixin of the belongsToMany association. * @see BelongsToManyHasAssociationsMixin */ - interface BelongsToManyHasAssociationsMixinOptions extends Transactable { } + interface BelongsToManyHasAssociationsMixinOptions { } /** * The removeAssociations mixin applied to models with belongsToMany. @@ -1128,7 +1129,7 @@ declare module "sequelize" { * The options for the countAssociations mixin of the belongsToMany association. * @see BelongsToManyCountAssociationsMixin */ - interface BelongsToManyCountAssociationsMixinOptions extends Transactable { + interface BelongsToManyCountAssociationsMixinOptions { /** * An optional where clause to limit the associated models. @@ -2537,7 +2538,7 @@ declare module "sequelize" { /** * Options used for Instance.increment method */ - interface InstanceIncrementDecrementOptions extends Transactable { + interface InstanceIncrementDecrementOptions { /** * The number to increment by @@ -2551,29 +2552,39 @@ declare module "sequelize" { */ logging? : boolean | Function; + /** + * Transaction to run query under + */ + transaction? : Transaction; + /** * A hash of attributes to describe your search. See above for examples. */ where? : WhereOptions | Array; - + } /** * Options used for Instance.restore method */ - interface InstanceRestoreOptions extends Transactable { + interface InstanceRestoreOptions { /** * A function that gets executed while running the query to log the sql. */ logging? : boolean | Function; - + + /** + * Transaction to run query under + */ + transaction? : Transaction; + } /** * Options used for Instance.destroy method */ - interface InstanceDestroyOptions extends Transactable { + interface InstanceDestroyOptions { /** * If set to true, paranoid models will actually be deleted @@ -2584,7 +2595,12 @@ declare module "sequelize" { * A function that gets executed while running the query to log the sql. */ logging? : boolean | Function; - + + /** + * Transaction to run the query in + */ + transaction? : Transaction; + } /** @@ -2619,7 +2635,7 @@ declare module "sequelize" { /** * Options used for Instance.save method */ - interface InstanceSaveOptions extends Transactable { + interface InstanceSaveOptions { /** * An optional array of strings, representing database columns. If fields is provided, only those columns @@ -2645,7 +2661,12 @@ declare module "sequelize" { * A function that gets executed while running the query to log the sql. */ logging? : boolean | Function; - + + /** + * Transaction to run the query in + */ + transaction? : Transaction; + } /** @@ -3070,7 +3091,7 @@ declare module "sequelize" { * * A hash of options to describe the scope of the search */ - interface FindOptions extends Transactable { + interface FindOptions { /** * A hash of attributes to describe your search. See above for examples. @@ -3117,6 +3138,11 @@ declare module "sequelize" { */ offset?: number; + /** + * Transaction to run query under + */ + transaction? : Transaction; + /** * Lock the selected rows. Possible options are transaction.LOCK.UPDATE and transaction.LOCK.SHARE. * Postgres also supports transaction.LOCK.KEY_SHARE, transaction.LOCK.NO_KEY_UPDATE and specific model @@ -3144,7 +3170,7 @@ declare module "sequelize" { /** * Options for Model.count method */ - interface CountOptions extends Transactable { + interface CountOptions { /** * A hash of search attributes. @@ -3177,7 +3203,8 @@ declare module "sequelize" { * A function that gets executed while running the query to log the sql. */ logging? : boolean | Function; - + + transaction?: Transaction; } /** @@ -3207,7 +3234,7 @@ declare module "sequelize" { /** * Options for Model.create method */ - interface CreateOptions extends BuildOptions, Transactable { + interface CreateOptions extends BuildOptions { /** * If set, only columns matching those in fields will be saved @@ -3219,6 +3246,11 @@ declare module "sequelize" { */ onDuplicate? : string; + /** + * Transaction to run query under + */ + transaction? : Transaction; + /** * A function that gets executed while running the query to log the sql. */ @@ -3227,13 +3259,12 @@ declare module "sequelize" { silent? : boolean; returning? : boolean; - } /** * Options for Model.findOrInitialize method */ - interface FindOrInitializeOptions extends Transactable { + interface FindOrInitializeOptions { /** * A hash of search attributes. @@ -3245,6 +3276,11 @@ declare module "sequelize" { */ defaults? : TAttributes; + /** + * Transaction to run query under + */ + transaction? : Transaction; + /** * A function that gets executed while running the query to log the sql. */ @@ -3277,7 +3313,7 @@ declare module "sequelize" { /** * Options for Model.bulkCreate method */ - interface BulkCreateOptions extends Transactable { + interface BulkCreateOptions { /** * Fields to insert (defaults to all fields) @@ -3314,6 +3350,11 @@ declare module "sequelize" { */ updateOnDuplicate? : Array; + /** + * Transaction to run query under + */ + transaction? : Transaction; + /** * A function that gets executed while running the query to log the sql. */ @@ -3324,7 +3365,12 @@ declare module "sequelize" { /** * The options passed to Model.destroy in addition to truncate */ - interface TruncateOptions extends Transactable { + interface TruncateOptions { + + /** + * Transaction to run query under + */ + transaction? : Transaction; /** * Only used in conjuction with TRUNCATE. Truncates all tables that have foreign-key references to the @@ -3383,7 +3429,7 @@ declare module "sequelize" { /** * Options for Model.restore */ - interface RestoreOptions extends Transactable { + interface RestoreOptions { /** * Filter the restore @@ -3411,12 +3457,17 @@ declare module "sequelize" { */ logging? : boolean | Function; + /** + * Transaction to run query under + */ + transaction? : Transaction; + } /** * Options used for Model.update */ - interface UpdateOptions extends Transactable { + interface UpdateOptions { /** * Options to describe the scope of the search. @@ -3473,6 +3524,11 @@ declare module "sequelize" { */ logging? : boolean | Function; + /** + * Transaction to run query under + */ + transaction? : Transaction; + } /** @@ -4366,7 +4422,7 @@ declare module "sequelize" { * * @see Options */ - interface QueryOptions extends Transactable { + interface QueryOptions { /** * If true, sequelize will not try to format the results of the query, or build an instance of a model from @@ -4374,6 +4430,11 @@ declare module "sequelize" { */ raw?: boolean; + /** + * The transaction that the query should be executed under + */ + transaction?: Transaction; + /** * The type of query you are executing. The query type affects how results are formatted before they are * passed back. The type is a string, but `Sequelize.QueryTypes` is provided as convenience shortcuts. @@ -5777,18 +5838,7 @@ declare module "sequelize" { * A function that gets executed while running the query to log the sql. */ logging?: Function; - } - - /** - * An interface that allows an item to support working under a transaction - * - * @param transaction Transaction The optional transaction to run under - */ - interface Transactable { - /** - * Transaction to run query under - */ - transaction?: Transaction; + } // From 41b42c1609ce6f0b48af2952de352d0525e828e7 Mon Sep 17 00:00:00 2001 From: James O'Cull Date: Wed, 9 Dec 2015 17:08:36 -0500 Subject: [PATCH 4/4] QueryInterface should have `sequelize` property --- sequelize/sequelize.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sequelize/sequelize.d.ts b/sequelize/sequelize.d.ts index 46a0ba41a0..3f1e2c86fc 100644 --- a/sequelize/sequelize.d.ts +++ b/sequelize/sequelize.d.ts @@ -3949,6 +3949,11 @@ declare module "sequelize" { * We don't have a definition for the QueryGenerator, because I doubt it is commonly in use separately. */ QueryGenerator: any; + + /** + * Returns the current sequelize instance. + */ + sequelize: Sequelize; /** * Queries the schema (table list).