aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/database-utils.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-01-04 14:04:02 +0100
committerChocobozzz <me@florianbigard.com>2018-01-04 14:04:02 +0100
commita5625b416797fa20f7cccead6201f3faf9427080 (patch)
tree089ad8155f924385d5f528c96cbcec1b52f56c72 /server/helpers/database-utils.ts
parent4cb6d4578893db310297d7e118ce2fb7ecb952a3 (diff)
downloadPeerTube-a5625b416797fa20f7cccead6201f3faf9427080.tar.gz
PeerTube-a5625b416797fa20f7cccead6201f3faf9427080.tar.zst
PeerTube-a5625b416797fa20f7cccead6201f3faf9427080.zip
Refresh remote accounts
Diffstat (limited to 'server/helpers/database-utils.ts')
-rw-r--r--server/helpers/database-utils.ts12
1 files changed, 11 insertions, 1 deletions
diff --git a/server/helpers/database-utils.ts b/server/helpers/database-utils.ts
index fb8ad22b0..78ca768b9 100644
--- a/server/helpers/database-utils.ts
+++ b/server/helpers/database-utils.ts
@@ -1,5 +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 } from 'sequelize-typescript'
3import { logger } from './logger' 4import { logger } from './logger'
4 5
5type RetryTransactionWrapperOptions = { errorMessage: string, arguments?: any[] } 6type RetryTransactionWrapperOptions = { errorMessage: string, arguments?: any[] }
@@ -34,9 +35,18 @@ function transactionRetryer <T> (func: (err: any, data: T) => any) {
34 }) 35 })
35} 36}
36 37
38function updateInstanceWithAnother <T> (instanceToUpdate: Model<T>, baseInstance: Model<T>) {
39 const obj = baseInstance.toJSON()
40
41 for (const key of Object.keys(obj)) {
42 instanceToUpdate.set(key, obj[key])
43 }
44}
45
37// --------------------------------------------------------------------------- 46// ---------------------------------------------------------------------------
38 47
39export { 48export {
40 retryTransactionWrapper, 49 retryTransactionWrapper,
41 transactionRetryer 50 transactionRetryer,
51 updateInstanceWithAnother
42} 52}