UNPKG

paradigm-core

Version:
68 lines (46 loc) 1 kB
const {r, RootModel} = require('structure-core') /** * ThemeModel Class * * @public * @class ThemeModel */ class ThemeModel extends RootModel { /** * ThemeModel constructor * * @public * @constructor * @param {Object} options - Options */ constructor(options = {}) { super(Object.assign({}, { table: 'themes', relations: {} }, options)) } getAll(ids = [], options = {}) { const applicationId = options.applicationId return new Promise( async (resolve, reject) => { try { let query = r .table(this.table) if(ids.length > 0) { query = query .getAll(r.args(ids)) } else { query = query .getAll(applicationId, {index: 'applicationId'}) } const themes = await query.run() resolve(themes) } catch(e) { this.logger.error(e) reject(e) } }) } } module.exports = ThemeModel