aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers')
-rw-r--r--server/helpers/database-utils.ts9
1 files changed, 9 insertions, 0 deletions
diff --git a/server/helpers/database-utils.ts b/server/helpers/database-utils.ts
index da8fb0d54..b6ba7fd75 100644
--- a/server/helpers/database-utils.ts
+++ b/server/helpers/database-utils.ts
@@ -68,6 +68,14 @@ function transactionRetryer <T> (func: (err: any, data: T) => any) {
68 }) 68 })
69} 69}
70 70
71function saveInTransactionWithRetries <T extends Pick<Model, 'save'>> (model: T) {
72 return retryTransactionWrapper(() => {
73 return sequelizeTypescript.transaction(async transaction => {
74 await model.save({ transaction })
75 })
76 })
77}
78
71// --------------------------------------------------------------------------- 79// ---------------------------------------------------------------------------
72 80
73function resetSequelizeInstance <T> (instance: Model<T>) { 81function resetSequelizeInstance <T> (instance: Model<T>) {
@@ -105,6 +113,7 @@ export {
105 resetSequelizeInstance, 113 resetSequelizeInstance,
106 retryTransactionWrapper, 114 retryTransactionWrapper,
107 transactionRetryer, 115 transactionRetryer,
116 saveInTransactionWithRetries,
108 afterCommitIfTransaction, 117 afterCommitIfTransaction,
109 filterNonExistingModels, 118 filterNonExistingModels,
110 deleteAllModels, 119 deleteAllModels,