refactor: remove config namespaces
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
const Model = require('objection').Model
|
||||
const _ = require('lodash')
|
||||
|
||||
/* global WIKI */
|
||||
|
||||
/**
|
||||
* Settings model
|
||||
*/
|
||||
module.exports = class User extends Model {
|
||||
module.exports = class Setting extends Model {
|
||||
static get tableName() { return 'settings' }
|
||||
|
||||
static get jsonSchema () {
|
||||
@@ -25,7 +28,18 @@ module.exports = class User extends Model {
|
||||
this.updatedAt = new Date().toISOString()
|
||||
}
|
||||
$beforeInsert() {
|
||||
this.createdAt = new Date().toISOString()
|
||||
this.updatedAt = new Date().toISOString()
|
||||
}
|
||||
|
||||
static async getConfig() {
|
||||
const settings = await WIKI.db.settings.query()
|
||||
if (settings.length > 0) {
|
||||
return _.reduce(settings, (res, val, key) => {
|
||||
_.set(res, val.key, (val.value.v) ? val.value.v : val.value)
|
||||
return res
|
||||
}, {})
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user