querries traen solo lo que necesitan
This commit is contained in:
@@ -15,16 +15,31 @@ const admin = async (body) => {
|
||||
return CasoEspecial.findOne({
|
||||
where: { idCasoEspecial },
|
||||
include: [
|
||||
{ model: Usuario, include: [{ model: TipoUsuario }] },
|
||||
{
|
||||
model: Usuario,
|
||||
include: [{ model: TipoUsuario }],
|
||||
attributes: ['idUsuario', 'usuario', 'nombre'],
|
||||
},
|
||||
{ model: Carrera },
|
||||
{ model: Status },
|
||||
],
|
||||
attributes: [
|
||||
'idCasoEspecial',
|
||||
'creditos',
|
||||
'correo',
|
||||
'telefono',
|
||||
'institucion',
|
||||
'dependencia',
|
||||
'motivo',
|
||||
'direccion',
|
||||
'fechaInicio',
|
||||
'fechaFin',
|
||||
'fechaNacimiento',
|
||||
'archivoZip',
|
||||
'createdAt',
|
||||
],
|
||||
}).then((res) => {
|
||||
if (!res) throw new Error('No existe este Caso Especial.');
|
||||
delete res.dataValues.Usuario.dataValues.password;
|
||||
delete res.dataValues.idUsuario;
|
||||
delete res.dataValues.idCarrera;
|
||||
delete res.dataValues.idStatus;
|
||||
return res;
|
||||
});
|
||||
};
|
||||
|
||||
@@ -35,19 +35,16 @@ const serviciosEspeciales = async (body) => {
|
||||
{ nombre: { [Op.like]: `%${nombre}%` } },
|
||||
],
|
||||
},
|
||||
attributes: ['idUsuario', 'usuario', 'nombre'],
|
||||
},
|
||||
{ model: Carrera },
|
||||
{ model: Status, where },
|
||||
],
|
||||
attributes: ['idCasoEspecial', 'fechaInicio', 'fechaFin', 'createdAt'],
|
||||
order: [['updatedAt', 'DESC']],
|
||||
limit: 25,
|
||||
offset: 25 * (pagina - 1),
|
||||
}).then((res) => {
|
||||
for (let i = 0; i < res.rows.length; i++) {
|
||||
// delete res.rows[i].dataValues.idUsuario
|
||||
}
|
||||
return { count: res.count, serviciosEspeciales: res.rows };
|
||||
});
|
||||
}).then((res) => ({ count: res.count, serviciosEspeciales: res.rows }));
|
||||
};
|
||||
|
||||
module.exports = serviciosEspeciales;
|
||||
|
||||
Reference in New Issue
Block a user