From b2399d486ebc3c329580018d258d933d1c7c2516 Mon Sep 17 00:00:00 2001 From: Muhammad Afif Date: Thu, 16 Oct 2025 15:25:01 +0700 Subject: [PATCH] revisi db tags: add device_code_name --- db/device.db.js | 38 ++++++++------------------------------ 1 file changed, 8 insertions(+), 30 deletions(-) diff --git a/db/device.db.js b/db/device.db.js index 851ba60..c28d9a0 100644 --- a/db/device.db.js +++ b/db/device.db.js @@ -40,22 +40,10 @@ const getAllDevicesDb = async (searchParams = {}) => { const queryText = ` SELECT - COUNT(*) OVER() AS total_data, - a.device_id, - a.device_code, - a.device_name, - a.is_active, - a.device_location, - a.device_description, - a.ip_address, - a.created_by, - a.updated_by, - a.deleted_by, - a.created_at, - a.updated_at, - a.deleted_at, - b.brand_id, - b.brand_name + COUNT(*) OVER() AS total_data, + a.*, + b.brand_name, + COALESCE(a.device_code, '') + ' - ' + COALESCE(a.device_name, '') AS device_code_name FROM m_device a LEFT JOIN m_brands b ON a.brand_id = b.brand_id WHERE a.deleted_at IS NULL @@ -78,20 +66,10 @@ const getAllDevicesDb = async (searchParams = {}) => { const getDeviceByIdDb = async (id) => { const queryText = ` - SELECT - a.device_id, - a.device_name, - a.is_active, - a.device_location, - a.device_description, - a.ip_address, - a.created_by, - a.updated_by, - a.deleted_by, - a.created_at, - a.updated_at, - a.deleted_at, - b.brand_name + SELECT + a.*, + b.brand_name, + COALESCE(a.device_code, '') + ' - ' + COALESCE(a.device_name, '') AS device_code_name FROM m_device a LEFT JOIN m_brands b ON a.brand_id = b.brand_id WHERE a.device_id = $1 AND a.deleted_at IS NULL