]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/database-utils.ts
Fix retrying update on sql serialization conflict
[github/Chocobozzz/PeerTube.git] / server / helpers / database-utils.ts
index 62738108607f650af0ca63b25de506f4fb4de03f..0e6b3550371e721624652166ea03d2435538b5c6 100644 (file)
@@ -78,10 +78,8 @@ function updateInstanceWithAnother <M, T extends U, U extends Model<M>> (instanc
   }
 }
 
-function resetSequelizeInstance (instance: Model<any>, savedFields: object) {
-  Object.keys(savedFields).forEach(key => {
-    instance[key] = savedFields[key]
-  })
+function resetSequelizeInstance <T> (instance: Model<T>) {
+  instance.set(instance.previous())
 }
 
 function filterNonExistingModels <T extends { hasSameUniqueKeysThan (other: T): boolean }> (