fix(backend) Para solucionar duplicação do nome do usuario no dasboard

adriano 2023-10-23 09:01:38 -03:00
parent dcf471fa42
commit 0d32fe8fbb
1 changed files with 21 additions and 19 deletions

View File

@ -37,32 +37,34 @@ const ListUser = async ({ profile, userId, raw}: Request): Promise<User[]> => {
}
const users = await User.findAll({
const queryOptions:any = {
where: where_clause,
raw,
attributes: ['id', 'name', 'email'],
attributes: ["id", "name", "email"],
order: [["id", "ASC"]]
};
include: [
if (!raw) {
queryOptions.include = [
{ model: Queue, as: "queues", attributes: ["id", "name", "color"] }
],
];
}
// include: [
// {
// model: UserQueue,
// separate: true,
// attributes: ['id',],
// order: [
// ['createdAt', 'ASC']
// ]
// },
// ],
const users = await User.findAll(queryOptions);
order: [["id", "ASC"]],
})
// const users = await User.findAll({
// where: where_clause,
// raw,
// attributes: ['id', 'name', 'email'],
// include: [
// { model: Queue, as: "queues", attributes: ["id", "name", "color"] }
// ],
// order: [["id", "ASC"]],
// })
return users;