Files
xXpuma99Xx e960e3fd72 meh
2021-10-24 20:20:04 -05:00

22 lines
644 B
JavaScript

const { validarNumeroCuenta } = require('../../helper/validar');
const dbPath = '../../db/tablas';
const Alumno = require(`${dbPath}/Alumno`);
const Carrera = require(`${dbPath}/Carrera`);
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.');
if (res.idHorario)
throw new Error('Este alumno ya cuenta con un horario asignado.');
delete res.dataValues.idCarrera;
return res;
});
};
module.exports = get;