aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/database-utils.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-08-14 15:28:30 +0200
committerChocobozzz <me@florianbigard.com>2018-08-14 15:28:30 +0200
commit06215f15e0a9fea2ef95b8b49cb2b5868fb64017 (patch)
tree6f7ff9f82ea851ea87fd3fc4b61843c7a38aec43 /server/helpers/database-utils.ts
parent59c76ffa8f503e962d517c78f033f1beccb1de1a (diff)
downloadPeerTube-06215f15e0a9fea2ef95b8b49cb2b5868fb64017.tar.gz
PeerTube-06215f15e0a9fea2ef95b8b49cb2b5868fb64017.tar.zst
PeerTube-06215f15e0a9fea2ef95b8b49cb2b5868fb64017.zip
Cleanup utils helper
Diffstat (limited to 'server/helpers/database-utils.ts')
-rw-r--r--server/helpers/database-utils.ts10
1 files changed, 9 insertions, 1 deletions
diff --git a/server/helpers/database-utils.ts b/server/helpers/database-utils.ts
index 53f881fb3..1005d2cf1 100644
--- a/server/helpers/database-utils.ts
+++ b/server/helpers/database-utils.ts
@@ -1,6 +1,6 @@
1import * as retry from 'async/retry' 1import * as retry from 'async/retry'
2import * as Bluebird from 'bluebird' 2import * as Bluebird from 'bluebird'
3import { Model, Sequelize } from 'sequelize-typescript' 3import { Model } from 'sequelize-typescript'
4import { logger } from './logger' 4import { logger } from './logger'
5 5
6function retryTransactionWrapper <T, A, B, C> ( 6function retryTransactionWrapper <T, A, B, C> (
@@ -66,9 +66,17 @@ function updateInstanceWithAnother <T extends Model<T>> (instanceToUpdate: Model
66 } 66 }
67} 67}
68 68
69function resetSequelizeInstance (instance: Model<any>, savedFields: object) {
70 Object.keys(savedFields).forEach(key => {
71 const value = savedFields[key]
72 instance.set(key, value)
73 })
74}
75
69// --------------------------------------------------------------------------- 76// ---------------------------------------------------------------------------
70 77
71export { 78export {
79 resetSequelizeInstance,
72 retryTransactionWrapper, 80 retryTransactionWrapper,
73 transactionRetryer, 81 transactionRetryer,
74 updateInstanceWithAnother 82 updateInstanceWithAnother