get grupos

This commit is contained in:
Lemuel Marquez
2021-07-11 00:11:32 -05:00
parent 0122da685d
commit 3c781cffac
4 changed files with 41 additions and 1 deletions
+22
View File
@@ -0,0 +1,22 @@
const { Op } = require('sequelize');
const { validarId } = require('../../helper/validar');
const dbPath = '../../db/tablas';
const Carrera = require(`${dbPath}/Carrera`);
const Grupo = require(`${dbPath}/Grupo`);
const admin = async (body) => {
const idCarrera = validarId(body.idCarrera);
return Carrera.findOne({ where: { idCarrera } })
.then((res) => {
if (!res) throw new Error('No existe esta carrera.');
return Grupo.findAll({
where: { idCarrera, grupo: { [Op.like]: '11%' } },
});
})
.then((res) => {
return res;
});
};
module.exports = admin;