29 lines
865 B
JavaScript
29 lines
865 B
JavaScript
const { Op } = require('sequelize');
|
|
const dbPath = '../../db/tablas';
|
|
const Usuario = require(`${dbPath}/Usuario`);
|
|
const Inscripcion = require(`${dbPath}/Inscripcion`);
|
|
const { validarNumeroEntero } = require('../../helper/validar');
|
|
|
|
const todasInscripciones = async (body) => {
|
|
const validacion = validarNumeroEntero(body.validacion, 'validacion', true);
|
|
const order = validacion === 2 ? [['idInscripcion', 'ASC']] : [['idInscripcion', 'DESC']];
|
|
console.log(order)
|
|
return Inscripcion.findAll({
|
|
where: {
|
|
validacion,
|
|
cancelacion: 0,
|
|
idPeriodo: Number(process.env.PERIODO),
|
|
},
|
|
order: order,
|
|
include: [
|
|
{
|
|
model: Usuario,
|
|
where: { numeroCuenta: { [Op.like]: `%${body.numeroCuenta}%` } },
|
|
attributes: ['idUsuario', 'numeroCuenta'],
|
|
},
|
|
],
|
|
});
|
|
};
|
|
|
|
module.exports = todasInscripciones;
|