1
0
Fork 0
This repository has been archived on 2024-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
letu/sockets/get/evaluationGet.js

23 lines
763 B
JavaScript
Raw Normal View History

const models = require("../../models");
module.exports = socket => {
return async (data) => {
const options = {where: {},
include: [models.UE, {model: models.User},
{
model: models.Grade,
include: [{model: models.User, as: "TeacherGrade"}, {model: models.User, as: "StudentGrade"}]
}]
};
if (data && data.id)
options.where.id = data.id;
if (socket.request.session.user.permissions === 2) {
options.include[1].where = {email: socket.request.session.user.email};
options.include[1].required = true;
}
socket.emit("evaluationGet", await models.Evaluation.findAll(options));
}
};