* Commit the transaction * * @returns {Promise}
()
| 52 | * @returns {Promise} |
| 53 | */ |
| 54 | async commit() { |
| 55 | if (this.finished) { |
| 56 | throw new Error(`Transaction cannot be committed because it has been finished with state: ${this.finished}`); |
| 57 | } |
| 58 | |
| 59 | try { |
| 60 | return await this.sequelize.getQueryInterface().commitTransaction(this, this.options); |
| 61 | } finally { |
| 62 | this.finished = class="st">'commit'; |
| 63 | this.cleanup(); |
| 64 | for (const hook of this._afterCommitHooks) { |
| 65 | await hook.apply(this, [this]); |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Rollback (abort) the transaction |