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

24 lines
781 B
JavaScript
Raw Normal View History

2021-01-20 17:14:33 +01:00
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));
}
};