wikijs-fork/server/models/navigation.js

34 lines
709 B
JavaScript
Raw Normal View History

const Model = require('objection').Model
/* global WIKI */
/**
* Navigation model
*/
module.exports = class Navigation extends Model {
static get tableName() { return 'navigation' }
static get idColumn() { return 'key' }
static get jsonSchema () {
return {
type: 'object',
required: ['key'],
properties: {
key: {type: 'string'},
2018-10-22 02:25:17 +00:00
config: {type: 'array', items: {type: 'object'}}
}
}
}
static async getTree() {
2018-10-22 02:25:17 +00:00
const navTree = await WIKI.models.navigation.query().findOne('key', 'site')
if (navTree) {
return navTree.config
} else {
WIKI.logger.warn('Site Navigation is missing or corrupted.')
return []
}
}
}