Files
pcpuma_acatlan_api/server/controller/Carrito/equiposCarrito.js
T

27 lines
813 B
JavaScript
Raw Normal View History

2022-01-03 16:47:25 -06:00
const { validarNumeroEntero } = require('../../helper/validar');
2021-05-26 19:14:11 -05:00
const dbPath = '../../db/tablas';
const Carrito = require(`${dbPath}/Carrito`);
2021-05-26 19:27:35 -05:00
const Equipo = require(`${dbPath}/Equipo`);
const Programa = require(`${dbPath}/Programa`);
const Status = require(`${dbPath}/Status`);
2021-05-26 19:14:11 -05:00
2021-05-26 19:27:35 -05:00
const equiposCarrito = async (body) => {
2022-01-03 16:47:25 -06:00
const idCarrito = validarNumeroEntero(body.idCarrito, 'id carrito', true);
2021-05-26 19:27:35 -05:00
2022-01-20 22:01:14 -06:00
return Carrito.findOne({ where: { idCarrito } }).then((res) => {
if (!res) throw new Error('No existe este carrito.');
return Equipo.findAll({
where: { idCarrito },
include: [{ model: Status }, { model: Programa }],
attributes: [
'idEquipo',
'numeroSerie',
'numeroInventario',
'sobrenombre',
],
2021-05-26 19:27:35 -05:00
});
2022-01-20 22:01:14 -06:00
});
2021-05-26 19:27:35 -05:00
};
2021-05-26 19:14:11 -05:00
module.exports = equiposCarrito;