mini cambios#
This commit is contained in:
@@ -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 } });
|
||||
|
||||
Reference in New Issue
Block a user