/* global Venue */ 'use strict'; const _ = require('lodash'); const { generateService, parseParamsToFindOptions } = require('../../helpers/service.helper'); const models = require('../../core/models'); const extraMethods = { fetch: async (params, context) => { const type = context.type; const findOptions = parseParamsToFindOptions(params); console.log('ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZz'); console.log(findOptions); // findOptions.where = { 'name': '(Colegio Cristo Rey)'}; switch (type) { case 'college': // findOptions.where = Object.assign({}, // findOptions.where, { // 'EntityType.alias' : 'college' // }); break; case 'partner': // findOptions.where = Object.assign({}, // findOptions.where, { // date: { // [Sequelize.Op.gte]: moment().startOf('day').utc(), // [Sequelize.Op.lt]: moment().add(1, 'days').startOf('day').utc(), // } // }); break; default: break; } // Incluir findOptions.include.push({ model: models.EntityType, where: { alias: 'college' }, attributes: ['name'], }); // findOptions.include.push({ // model: models.EventType, // }); // findOptions.include.push({ // model: models.Venue, // }); findOptions.where = Object.assign({}, findOptions.where, { state: 'publish' }); try { return await models.Entity.findAll(findOptions); } catch (error) { throw error; } } }; module.exports = generateService(models.Entity, extraMethods);