30 lines
1.1 KiB
JavaScript
30 lines
1.1 KiB
JavaScript
const validar = require('../../helper/validar');
|
|
const dbPath = '../../db/tablas';
|
|
const Reporte = require(`${dbPath}/Reporte`);
|
|
const Prestamo = require(`${dbPath}/Prestamo`);
|
|
|
|
const historialReportes = async (body) => {
|
|
const idEquipo = validar.validarId(body.idEquipo);
|
|
const pagina = validar.validarNumero(body.pagina, true);
|
|
|
|
return Reporte.findAndCountAll({
|
|
// where: { idEquipo },
|
|
include: [{ model: Prestamo }],
|
|
limit: 25,
|
|
offset: 25 * (pagina - 1),
|
|
order: [['createdAt', 'DESC']],
|
|
}).then((res) => {
|
|
for (let i = 0; i < res.rows.length; i++) {
|
|
// delete res.rows[i].dataValues.idInfraccion;
|
|
// delete res.rows[i].dataValues.idPrestamo;
|
|
// delete res.rows[i].dataValues.Prestamo.dataValues.idOperadorEntrega;
|
|
// delete res.rows[i].dataValues.Prestamo.dataValues.idOperadorRegreso;
|
|
// delete res.rows[i].dataValues.Prestamo.dataValues.idUsuario;
|
|
// delete res.rows[i].dataValues.Prestamo.dataValues.idEquipo;
|
|
}
|
|
return { count: res.count, historialReportes: res.rows };
|
|
});
|
|
};
|
|
|
|
module.exports = historialReportes;
|