Files
inscripciones_api/server/controller/Usuario/escolares.js
T
2022-01-27 00:15:05 -06:00

36 lines
943 B
JavaScript

const { obtenerAlumno, obtenerCarrera } = require('../../config/mariadb.conf');
const validar = require('../../helper/validar');
const dbPath = '../../db/tablas';
const Carrera = require(`${dbPath}/Carrera`);
const Usuario = require(`${dbPath}/Usuario`);
const escolares = async (body) => {
// const numeroCuenta = validar.validarNumeroCuenta(body.numeroCuenta);
return Usuario.findOne({
where: { numeroCuenta: body.numeroCuenta },
}).then((res) => {
if (!res) {
return Usuario.create({
numeroCuenta: body.numeroCuenta,
nombre: body.nombre,
semestre: 8,
carrera: body.carrera,
});
}
return Usuario.findOne({
where: { numeroCuenta: body.numeroCuenta },
// include: [{ model: Carrera }],
attributes: [
'idUsuario',
'numeroCuenta',
'nombre',
'semestre',
'carrera',
],
});
});
};
module.exports = escolares;