25 lines
776 B
JavaScript
25 lines
776 B
JavaScript
const validar = require('../../helper/validar');
|
|
const Usuario = require('../../db/tablas/Usuario');
|
|
const Carrera = require('../../db/tablas/Carrera');
|
|
const TipoUsuario = require('../../db/tablas/TipoUsuario');
|
|
|
|
const get = async (body) => {
|
|
const pagina = validar.validarNumero(body.pagina);
|
|
|
|
return Usuario.findAndCountAll({
|
|
include: [{ model: TipoUsuario }, { model: Carrera }],
|
|
limit: 25,
|
|
offset: 25 * (pagina - 1),
|
|
}).then((res) => {
|
|
for (let i = 0; i < res.rows.length; i++) {
|
|
delete res.rows[i].dataValues.password;
|
|
delete res.rows[i].dataValues.idTipoUsuario;
|
|
delete res.rows[i].dataValues.idCarrera;
|
|
if (!res.rows[i].Carrera) delete res.rows[i].dataValues.Carrera;
|
|
}
|
|
return res;
|
|
});
|
|
};
|
|
|
|
module.exports = get;
|