MCPcopy
hub / github.com/sequelize/sequelize / rollback

Method rollback

src/transaction.js:81–103  ·  view source on GitHub ↗

* Rollback (abort) the transaction * * @returns {Promise}

()

Source from the content-addressed store, hash-verified

79 * @returns {Promise}
80 */
81 async rollback() {
82 if (this.finished) {
83 throw new Error(`Transaction cannot be rolled back because it has been finished with state: ${this.finished}`);
84 }
85
86 if (!this.connection) {
87 throw new Error('Transaction cannot be rolled back because it never started');
88 }
89
90 try {
91 await this
92 .sequelize
93 .getQueryInterface()
94 .rollbackTransaction(this, this.options);
95
96 this.cleanup();
97 } catch (e) {
98 console.warn(`Rolling back transaction ${this.id} failed with error ${JSON.stringify(e.message)}. We are killing its connection as it is now in an undetermined state.`);
99 await this.forceCleanup();
100
101 throw e;
102 }
103 }
104
105 /**
106 * Called to acquire a connection to use and set the correct options on the connection.

Callers 15

transactionMethod · 0.95
prepareEnvironmentMethod · 0.95
cls.test.jsFile · 0.80
model.test.jsFile · 0.80
testAsyncFunction · 0.80
sequelize.test.jsFile · 0.80
has-one.test.jsFile · 0.80
has-many.test.jsFile · 0.80
belongs-to.test.jsFile · 0.80

Calls 6

cleanupMethod · 0.95
forceCleanupMethod · 0.95
rollbackTransactionMethod · 0.80
getQueryInterfaceMethod · 0.80
warnMethod · 0.65
stringifyMethod · 0.65

Tested by 1

testAsyncFunction · 0.64