equipos de un carrito listo
This commit is contained in:
@@ -1,9 +1,29 @@
|
||||
const validar = require('../../helper/validar');
|
||||
const dbPath = '../../db/tablas';
|
||||
const Carrito = require(`${dbPath}/Carrito`);
|
||||
const Modulo = require(`${dbPath}/Modulo`);
|
||||
const TipoCarrito = require(`${dbPath}/TipoCarrito`);
|
||||
const Equipo = require(`${dbPath}/Equipo`);
|
||||
const Programa = require(`${dbPath}/Programa`);
|
||||
const Status = require(`${dbPath}/Status`);
|
||||
|
||||
const equiposCarrito = async (body) => {};
|
||||
const equiposCarrito = async (body) => {
|
||||
const idCarrito = validar.validarId(body.idCarrito);
|
||||
|
||||
return Carrito.findOne({ where: { idCarrito } })
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('No existe este carrito.');
|
||||
return Equipo.findAndCountAll({
|
||||
where: { idCarrito },
|
||||
include: [{ model: Status }, { model: Programa }],
|
||||
});
|
||||
})
|
||||
.then((res) => {
|
||||
for (let i = 0; i < res.rows.length; i++) {
|
||||
delete res.rows[i].dataValues.idCarrito;
|
||||
delete res.rows[i].dataValues.idStatus;
|
||||
delete res.rows[i].dataValues.idPrograma;
|
||||
}
|
||||
return { count: res.count, equiposCarrito: res.rows };
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = equiposCarrito;
|
||||
|
||||
Reference in New Issue
Block a user