This commit is contained in:
David Arranz 2019-07-09 22:14:51 +02:00
parent 522257517c
commit 37e1eb1af7
3 changed files with 0 additions and 44 deletions

View File

@ -10,16 +10,6 @@ const MODULE_NAME = '[value.controller]';
const controllerOptions = { MODULE_NAME };
const extraControllers = {
findSpeakers: async (req, res, next) => {
const params = extractParamsFromRequest(req, res, {});
try {
const result = await valueService.associationFetchAll(params, { user: req.user });
console.log(result);
return handleResultResponse(result, result.count, params, res);
} catch (error) {
handleErrorResponse(MODULE_NAME, 'findNext', error, res);
}
},
};
module.exports = generateControllers(valueService, extraControllers, controllerOptions);

View File

@ -39,15 +39,4 @@ routes.get('/values/:id/:association',
);
routes.get('/values/:id/speakers/:speakerId',
//isLoggedUser,
FieldMiddleware.middleware({
invalidFields: ['createdAt']
}),
PaginateMiddleware.middleware(),
SortMiddleware.middleware({ default: "name" }),
valueController.findSpeakers
);
module.exports = routes;

View File

@ -86,29 +86,6 @@ function extractParams(params) {
}
const extraMethods = {
associationFetchAll: async (params, context) => {
async function fetchOne(params, context) {
const findOptions = parseParamsToFindOptions(params);
return await model.findOne({
where: findOptions.where,
include: findOptions.include
});
};
const model = models.Value;
const associationName = params.params.association;
delete params.params.association;
const associationInfo = foundModelAssociation(model, associationName);
if (associationInfo) {
const result = await fetchOne(params, context);
const prueba = await result[associationInfo.getFunc]();
return prueba;
} else {
throw new Error('error');
}
}
};
module.exports = generateService(models.Value, extraMethods);