diff options
Diffstat (limited to 'server/helpers/database-utils.ts')
-rw-r--r-- | server/helpers/database-utils.ts | 10 |
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 @@ | |||
1 | import * as retry from 'async/retry' | 1 | import * as retry from 'async/retry' |
2 | import * as Bluebird from 'bluebird' | 2 | import * as Bluebird from 'bluebird' |
3 | import { Model, Sequelize } from 'sequelize-typescript' | 3 | import { Model } from 'sequelize-typescript' |
4 | import { logger } from './logger' | 4 | import { logger } from './logger' |
5 | 5 | ||
6 | function retryTransactionWrapper <T, A, B, C> ( | 6 | function retryTransactionWrapper <T, A, B, C> ( |
@@ -66,9 +66,17 @@ function updateInstanceWithAnother <T extends Model<T>> (instanceToUpdate: Model | |||
66 | } | 66 | } |
67 | } | 67 | } |
68 | 68 | ||
69 | function 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 | ||
71 | export { | 78 | export { |
79 | resetSequelizeInstance, | ||
72 | retryTransactionWrapper, | 80 | retryTransactionWrapper, |
73 | transactionRetryer, | 81 | transactionRetryer, |
74 | updateInstanceWithAnother | 82 | updateInstanceWithAnother |