2022-01-03 16:47:25 -06:00
|
|
|
const { validarNumeroEntero } = require('../../helper/validar');
|
2021-05-26 19:47:13 -05:00
|
|
|
const dbPath = '../../db/tablas';
|
|
|
|
|
const Carrito = require(`${dbPath}/Carrito`);
|
|
|
|
|
const Modulo = require(`${dbPath}/Modulo`);
|
2021-09-20 00:21:36 -05:00
|
|
|
const TipoCarrito = require(`${dbPath}/TipoCarrito`);
|
2021-05-26 19:47:13 -05:00
|
|
|
|
2021-09-20 00:21:36 -05:00
|
|
|
const carrito = async (body) => {
|
2022-01-03 16:47:25 -06:00
|
|
|
const idCarrito = validarNumeroEntero(body.idCarrito, 'id carrito', true);
|
2021-05-26 19:47:13 -05:00
|
|
|
|
|
|
|
|
return Carrito.findOne({
|
|
|
|
|
where: { idCarrito },
|
|
|
|
|
include: [{ model: TipoCarrito }, { model: Modulo }],
|
2022-02-13 12:33:38 -06:00
|
|
|
attributes: ['idCarrito', 'carrito', 'activo'],
|
2021-05-26 19:47:13 -05:00
|
|
|
}).then((res) => {
|
|
|
|
|
if (!res) throw new Error('No existe este carrito.');
|
|
|
|
|
return res;
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2021-09-20 00:21:36 -05:00
|
|
|
module.exports = carrito;
|