aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-05-11 15:02:53 +0200
committerChocobozzz <me@florianbigard.com>2023-05-11 15:03:47 +0200
commit823c34c07fc0df81110098ee1032e9d3ed70b662 (patch)
tree4d15bc0e09766552434ee50ad5f6098bd2f74ac4 /server/helpers
parent81f14b911211be065448e92bcc253f470c5ff2a9 (diff)
downloadPeerTube-823c34c07fc0df81110098ee1032e9d3ed70b662.tar.gz
PeerTube-823c34c07fc0df81110098ee1032e9d3ed70b662.tar.zst
PeerTube-823c34c07fc0df81110098ee1032e9d3ed70b662.zip
Fix reset sequelize instance
Diffstat (limited to 'server/helpers')
-rw-r--r--server/helpers/database-utils.ts11
1 files changed, 1 insertions, 10 deletions
diff --git a/server/helpers/database-utils.ts b/server/helpers/database-utils.ts
index 0e6b35503..da8fb0d54 100644
--- a/server/helpers/database-utils.ts
+++ b/server/helpers/database-utils.ts
@@ -70,16 +70,8 @@ function transactionRetryer <T> (func: (err: any, data: T) => any) {
70 70
71// --------------------------------------------------------------------------- 71// ---------------------------------------------------------------------------
72 72
73function updateInstanceWithAnother <M, T extends U, U extends Model<M>> (instanceToUpdate: T, baseInstance: U) {
74 const obj = baseInstance.toJSON()
75
76 for (const key of Object.keys(obj)) {
77 instanceToUpdate[key] = obj[key]
78 }
79}
80
81function resetSequelizeInstance <T> (instance: Model<T>) { 73function resetSequelizeInstance <T> (instance: Model<T>) {
82 instance.set(instance.previous()) 74 return instance.reload()
83} 75}
84 76
85function filterNonExistingModels <T extends { hasSameUniqueKeysThan (other: T): boolean }> ( 77function filterNonExistingModels <T extends { hasSameUniqueKeysThan (other: T): boolean }> (
@@ -113,7 +105,6 @@ export {
113 resetSequelizeInstance, 105 resetSequelizeInstance,
114 retryTransactionWrapper, 106 retryTransactionWrapper,
115 transactionRetryer, 107 transactionRetryer,
116 updateInstanceWithAnother,
117 afterCommitIfTransaction, 108 afterCommitIfTransaction,
118 filterNonExistingModels, 109 filterNonExistingModels,
119 deleteAllModels, 110 deleteAllModels,