From 0d32fe8fbb6f13cd0ef7c0607782ff767858bde3 Mon Sep 17 00:00:00 2001 From: adriano Date: Mon, 23 Oct 2023 09:01:38 -0300 Subject: [PATCH] =?UTF-8?q?fix(backend)=20Para=20solucionar=20duplica?= =?UTF-8?q?=C3=A7=C3=A3o=20do=20nome=20do=20usuario=20no=20dasboard?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UserServices/ListUserParamiterService.ts | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/backend/src/services/UserServices/ListUserParamiterService.ts b/backend/src/services/UserServices/ListUserParamiterService.ts index 076674a..52bbfca 100644 --- a/backend/src/services/UserServices/ListUserParamiterService.ts +++ b/backend/src/services/UserServices/ListUserParamiterService.ts @@ -37,32 +37,34 @@ const ListUser = async ({ profile, userId, raw}: Request): Promise => { } - const users = await User.findAll({ + const queryOptions:any = { where: where_clause, raw, - attributes: ['id', 'name', 'email'], - - include: [ + attributes: ["id", "name", "email"], + order: [["id", "ASC"]] + }; + + 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;