不要怂,就是干,撸起袖子干!

Commit f1b0d034 by Mick Hansen

Merge pull request #5452 from Znarkus/patch-3

Clarify that transaction.commit() and rollback() returns a promise
2 parents d2fc3923 aab71d68
Showing with 3 additions and 3 deletions
...@@ -133,7 +133,7 @@ return sequelize.transaction({ ...@@ -133,7 +133,7 @@ return sequelize.transaction({
``` ```
# Unmanaged transaction (then-callback) # Unmanaged transaction (then-callback)
Unmanaged transactions force you to manually rollback or commit the transaction. If you don't do that, the transaction will hang until it times out. To start an unmanaged transaction, call `sequelize.transaction()` without a callback (you can still pass an options object) and call `then` on the returned promise. Unmanaged transactions force you to manually rollback or commit the transaction. If you don't do that, the transaction will hang until it times out. To start an unmanaged transaction, call `sequelize.transaction()` without a callback (you can still pass an options object) and call `then` on the returned promise. Notice that `commit()` and `rollback()` returns a promise.
```js ```js
return sequelize.transaction().then(function (t) { return sequelize.transaction().then(function (t) {
...@@ -146,9 +146,9 @@ return sequelize.transaction().then(function (t) { ...@@ -146,9 +146,9 @@ return sequelize.transaction().then(function (t) {
lastName: 'Simpson' lastName: 'Simpson'
}, {transaction: t}); }, {transaction: t});
}).then(function () { }).then(function () {
t.commit(); return t.commit();
}).catch(function (err) { }).catch(function (err) {
t.rollback(); return t.rollback();
}); });
}); });
``` ```
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!