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/studentGet.js

23 lines
781 B
JavaScript

const models = require("../../models");
module.exports = socket => {
return async (data) => {
let options = {
attributes: ["email", "firstName", "lastName"],
where: {permissions: 1},
include: [{model: models.Group, include: models.Semester}]
};
if (data && data.email)
options.where.email = data.email;
if (data && data.firstName && data.lastName) {
options.where.firstName = data.firstName;
options.where.lastName = data.lastName;
}
if (data && data.group) {
options.include[0].where = {id: data.group};
options.include[0].required = true;
}
socket.emit("studentGet", await models.User.findAll(options));
}
};