UNPKG

paradigm-core

Version:
69 lines (47 loc) 1.07 kB
const {r, RootModel} = require('structure-core') /** * SiteMapModel Class * * @public * @class SiteMapModel */ class SiteMapModel extends RootModel { /** * SiteMapModel constructor * * @public * @constructor * @param {Object} options - Options */ constructor(options = {}) { super(Object.assign({}, { table: 'sitemaps', relations: {} }, options)) } getAll(ids = [], options = {}) { const applicationId = options.applicationId const organizationId = options.organizationId 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 sitemaps = await query.run() resolve(sitemaps) } catch(e) { this.logger.error(e) reject(e) } }) } } module.exports = SiteMapModel