aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers')
-rw-r--r--server/helpers/database-utils.js22
1 files changed, 20 insertions, 2 deletions
diff --git a/server/helpers/database-utils.js b/server/helpers/database-utils.js
index 046717517..6fe7e99aa 100644
--- a/server/helpers/database-utils.js
+++ b/server/helpers/database-utils.js
@@ -6,9 +6,27 @@ const db = require('../initializers/database')
6const logger = require('./logger') 6const logger = require('./logger')
7 7
8const utils = { 8const utils = {
9 commitTransaction,
9 retryTransactionWrapper, 10 retryTransactionWrapper,
10 transactionRetryer, 11 rollbackTransaction,
11 startSerializableTransaction 12 startSerializableTransaction,
13 transactionRetryer
14}
15
16function commitTransaction (t, callback) {
17 return t.commit().asCallback(callback)
18}
19
20function rollbackTransaction (err, t, callback) {
21 // Try to rollback transaction
22 if (t) {
23 // Do not catch err, report the original one
24 t.rollback().asCallback(function () {
25 return callback(err)
26 })
27 } else {
28 return callback(err)
29 }
12} 30}
13 31
14// { arguments, errorMessage } 32// { arguments, errorMessage }