const { obtenerIdCarrera, 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) => { return Usuario.findOne({ where: { numeroCuenta: body.numeroCuenta }, }).then((res) => { if (!res) { return obtenerIdCarrera(body.numeroCuenta).then(async (res) => { return Usuario.create({ idUsuario: body.idUsuario, numeroCuenta: body.numeroCuenta, nombre: body.nombre, semestre: 8, carrera: body.carrera, idCarrera: res.id_carrera, }); }); } return Usuario.findOne({ where: { numeroCuenta: body.numeroCuenta }, attributes: [ 'idUsuario', 'numeroCuenta', 'nombre', 'semestre', 'idCarrera', 'carrera', ], }); }); }; module.exports = escolares;