Files
citas_recorridos_api/server/controller/Alumno/get.js
T
2021-10-23 06:14:30 -05:00

20 lines
537 B
JavaScript

const { validarNumeroCuenta } = require('../../helper/validar');
const dbPath = '../../db/tablas';
const Carrera = require(`${dbPath}/Carrera`);
const Alumno = require(`${dbPath}/Alumno`);
const get = async (body) => {
const numeroCuenta = validarNumeroCuenta(body.numeroCuenta);
return Alumno.findOne({
where: { numeroCuenta },
include: [{ model: Carrera }],
}).then((res) => {
if (!res) throw new Error('No existe este número de cuenta.');
delete res.idCarrera;
return res;
});
};
module.exports = get;