mini cambios#

This commit is contained in:
xXpuma99Xx
2022-01-24 15:58:34 -06:00
parent 9af90dc0cf
commit ffadb76178
15 changed files with 119 additions and 111 deletions
+24 -18
View File
@@ -22,24 +22,30 @@ const update = async (body) => {
: null;
let update = {};
if (idStatus)
await Status.findOne({ where: { idStatus } }).then((res) => {
if (!res) throw new Error('No existe este status.');
update.idStatus = idStatus;
});
if (idCarrito)
await Carrito.findOne({ where: { idCarrito } }).then((res) => {
if (!res) throw new Error('No existe este carrito.');
update.idCarrito = idCarrito;
});
if (idPrograma)
await Programa.findOne({ where: { idPrograma } }).then((res) => {
if (!res) throw new Error('No existe este programa.');
update.idPrograma = idPrograma;
});
if (validar.validarObjetoVacio(update))
throw new Error('No se envio nada para actualizar.');
return Equipo.findOne({ where: { idEquipo } })
return Status.findOne({ where: { idStatus } })
.then((res) => {
if (idStatus) {
if (!res) throw new Error('No existe este status.');
update.idStatus = idStatus;
}
return Carrito.findOne({ where: { idCarrito } });
})
.then((res) => {
if (idCarrito) {
if (!res) throw new Error('No existe este carrito.');
update.idCarrito = idCarrito;
}
return Programa.findOne({ where: { idPrograma } });
})
.then((res) => {
if (idPrograma) {
if (!res) throw new Error('No existe este programa.');
update.idPrograma = idPrograma;
}
if (validar.validarObjetoVacio(update))
throw new Error('No se envio nada para actualizar.');
return Equipo.findOne({ where: { idEquipo } });
})
.then((res) => {
if (!res) throw new Error('No existe este equipo.');
return Equipo.update(update, { where: { idEquipo } });