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

24 lines
898 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,
2021-01-20 17:14:33 +01:00
include: [{attributes: ["email", "firstName", "lastName"], model: models.User, as: "TeacherGrade"},
{attributes: ["email", "firstName", "lastName"], model: models.User, as: "StudentGrade"}]
}]
};
if (data && data.id)
options.where.id = data.id;
if (socket.request.session.user.permissions === 2) {
2021-01-20 17:14:33 +01:00
options.include[0].through = {where: {UserEmail: socket.request.session.user.email}};
options.include[0].required = true;
}
socket.emit("evaluationGet", await models.Evaluation.findAll(options));
}
};