From 803a282823584f8d18cf7c080683148e73ffe527 Mon Sep 17 00:00:00 2001 From: Aji Kamaludin Date: Wed, 18 Aug 2021 21:33:59 +0700 Subject: [PATCH] fix typo --- src/api/users/handler.js | 4 ++-- src/services/postgres/UsersService.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/api/users/handler.js b/src/api/users/handler.js index 0455f64..e88b847 100644 --- a/src/api/users/handler.js +++ b/src/api/users/handler.js @@ -59,12 +59,12 @@ class UsersHandler { const { companyId } = request.auth.credentials; const { id: userId } = request.params; - const users = await this._service.getUserById({ userId, companyId }); + const user = await this._service.getUserById({ userId, companyId }); return { status: 'success', data: { - users, + user, }, }; } catch (error) { diff --git a/src/services/postgres/UsersService.js b/src/services/postgres/UsersService.js index 80f361e..3c8fcdd 100644 --- a/src/services/postgres/UsersService.js +++ b/src/services/postgres/UsersService.js @@ -79,7 +79,7 @@ class UsersService { const query = { text: ` - SELECT name, email, role FROM users WHERE company_id = $1 + SELECT id, name, email, role FROM users WHERE company_id = $1 ${q !== null ? `AND name ILIKE '%${q}%'` : ''} ORDER BY created_at DESC LIMIT $2 OFFSET $3`, @@ -102,7 +102,7 @@ class UsersService { validateUuid(userId); const query = { - text: 'SELECT name, email, role FROM users WHERE id = $1 AND company_id = $2', + text: 'SELECT id, name, email, role FROM users WHERE id = $1 AND company_id = $2', values: [userId, companyId], }; @@ -120,7 +120,7 @@ class UsersService { const query = { text: `SELECT - users.name, role, users.email, offices.id as officeId, companies.id as companyId + users.id, users.name, role, users.email, offices.id as officeId, companies.id as companyId FROM users LEFT JOIN companies ON companies.id = users.company_id LEFT JOIN offices ON companies.id = offices.company_id