* Rollback (abort) the transaction * * @returns {Promise}
()
| 73 | * @returns {Promise} |
| 74 | */ |
| 75 | async rollback() { |
| 76 | if (this.finished) { |
| 77 | throw new Error(`Transaction cannot be rolled back because it has been finished with state: ${this.finished}`); |
| 78 | } |
| 79 | |
| 80 | if (!this.connection) { |
| 81 | throw new Error(class="st">'Transaction cannot be rolled back because it never started'); |
| 82 | } |
| 83 | |
| 84 | try { |
| 85 | return await this |
| 86 | .sequelize |
| 87 | .getQueryInterface() |
| 88 | .rollbackTransaction(this, this.options); |
| 89 | } finally { |
| 90 | this.cleanup(); |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * Called to acquire a connection to use and set the correct options on the connection. |