Files
citas_recorridos_api/server/controller/TercerSemestre/get.js
T
2021-07-11 00:51:16 -05:00

24 lines
779 B
JavaScript

const { validarNumeroCuenta } = require('../../helper/validar');
const dbPath = '../../db/tablas';
const Carrera = require(`${dbPath}/Carrera`);
const Grupo = require(`${dbPath}/Grupo`);
const TercerSemestre = require(`${dbPath}/TercerSemestre`);
const get = async (body) => {
const numeroCuenta = validarNumeroCuenta(body.numeroCuenta);
return TercerSemestre.findOne({
where: { numeroCuenta },
include: [{ model: Grupo, include: [{ model: Carrera }] }],
}).then((res) => {
if (!res) throw new Error('No existe esta alumno.');
if (res.deseaAsistir)
throw new Error('Ya se registro a este alumno al recorrido.');
delete res.dataValues.idGrupo;
delete res.dataValues.Grupo.dataValues.idCarrera;
return res;
});
};
module.exports = get;