diff options
author | Chocobozzz <me@florianbigard.com> | 2023-05-11 15:02:53 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-05-11 15:03:47 +0200 |
commit | 823c34c07fc0df81110098ee1032e9d3ed70b662 (patch) | |
tree | 4d15bc0e09766552434ee50ad5f6098bd2f74ac4 /server/helpers | |
parent | 81f14b911211be065448e92bcc253f470c5ff2a9 (diff) | |
download | PeerTube-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.ts | 11 |
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 | ||
73 | function 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 | |||
81 | function resetSequelizeInstance <T> (instance: Model<T>) { | 73 | function resetSequelizeInstance <T> (instance: Model<T>) { |
82 | instance.set(instance.previous()) | 74 | return instance.reload() |
83 | } | 75 | } |
84 | 76 | ||
85 | function filterNonExistingModels <T extends { hasSameUniqueKeysThan (other: T): boolean }> ( | 77 | function 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, |