| 37 | module.exports = { |
| 38 | |
| 39 | async getSettingsVariables(dbc) { |
| 40 | const deferred = q.defer(); |
| 41 | const collection = dbc.db(config.globalDb).collection(config.globalSettings); |
| 42 | try { |
| 43 | const docs = await collection.find({}).toArray(); |
| 44 | if (docs.length) { |
| 45 | deferred.resolve(docs[0]); |
| 46 | } else { |
| 47 | throw 'No configuration found.'; |
| 48 | } |
| 49 | } catch (error) { |
| 50 | winston.error({ |
| 51 | error: String(error), |
| 52 | stack: new Error().stack, |
| 53 | }); |
| 54 | deferred.reject(error); |
| 55 | } |
| 56 | |
| 57 | return deferred.promise; |
| 58 | }, |
| 59 | |
| 60 | async initSettingsVariable(dbc) { |
| 61 | const deferred = q.defer(); |