28 lines
771 B
JavaScript
28 lines
771 B
JavaScript
const { validarNumeroEntero } = require('../../helper/validar');
|
|
const dbPath = '../../db/tablas';
|
|
const Motivo = require(`${dbPath}/Motivo`);
|
|
const Equipo = require(`${dbPath}/Equipo`);
|
|
const Status = require(`${dbPath}/Status`);
|
|
|
|
const historialMotivosEquipo = async (body) => {
|
|
const pagina = validarNumeroEntero(body.pagina, 'página', false);
|
|
const idEquipo = validarNumeroEntero(body.idEquipo, 'id equipo', true);
|
|
|
|
return Motivo.findAndCountAll({
|
|
include: [
|
|
{
|
|
model: Equipo,
|
|
where: { idEquipo },
|
|
attributes: [],
|
|
},
|
|
{ model: Status },
|
|
],
|
|
attributes: ['idMotivo', 'motivo'],
|
|
limit: 25,
|
|
offset: 25 * (pagina - 1),
|
|
order: [['idMotivo', 'DESC']],
|
|
});
|
|
};
|
|
|
|
module.exports = historialMotivosEquipo;
|