/* global Venue */
'use strict';

const _ = require('lodash');
const { generateService, parseParamsToFindOptions } = require('../../helpers/service.helper');
const models = require('../../core/models');
const { entityComposer } = require('../../helpers/composes.helper');


const extraMethods = {

    afterFetchAll: (result, params, context) => {

        if (!result.count) {
            return result;
        }

        let rows = result.rows.map(row => row.toJSON());
        rows = rows.map(entity => entityComposer(entity, context));

        return {
            count: result.count,
            rows: rows
        }
    },

};

module.exports = generateService(models.Entity, extraMethods);