]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/database-utils.ts
Add rate limit to registration and API endpoints
[github/Chocobozzz/PeerTube.git] / server / helpers / database-utils.ts
index 11304cafb684988f4c7ebedd88f7d05d0ef62290..39c74b2fdec9d87e791abb3de9be7b44dbc19083 100644 (file)
@@ -62,13 +62,20 @@ function updateInstanceWithAnother <T extends Model<T>> (instanceToUpdate: Model
   const obj = baseInstance.toJSON()
 
   for (const key of Object.keys(obj)) {
-    instanceToUpdate.set(key, obj[key])
+    instanceToUpdate[key] = obj[key]
   }
 }
 
+function resetSequelizeInstance (instance: Model<any>, savedFields: object) {
+  Object.keys(savedFields).forEach(key => {
+    instance[key] = savedFields[key]
+  })
+}
+
 // ---------------------------------------------------------------------------
 
 export {
+  resetSequelizeInstance,
   retryTransactionWrapper,
   transactionRetryer,
   updateInstanceWithAnother