revisi db tags: add device_code_name

This commit is contained in:
Muhammad Afif
2025-10-16 15:25:01 +07:00
parent a036326792
commit b2399d486e

View File

@@ -40,22 +40,10 @@ const getAllDevicesDb = async (searchParams = {}) => {
const queryText = ` const queryText = `
SELECT SELECT
COUNT(*) OVER() AS total_data, COUNT(*) OVER() AS total_data,
a.device_id, a.*,
a.device_code, b.brand_name,
a.device_name, COALESCE(a.device_code, '') + ' - ' + COALESCE(a.device_name, '') AS device_code_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
FROM m_device a FROM m_device a
LEFT JOIN m_brands b ON a.brand_id = b.brand_id LEFT JOIN m_brands b ON a.brand_id = b.brand_id
WHERE a.deleted_at IS NULL WHERE a.deleted_at IS NULL
@@ -78,20 +66,10 @@ const getAllDevicesDb = async (searchParams = {}) => {
const getDeviceByIdDb = async (id) => { const getDeviceByIdDb = async (id) => {
const queryText = ` const queryText = `
SELECT SELECT
a.device_id, a.*,
a.device_name, b.brand_name,
a.is_active, COALESCE(a.device_code, '') + ' - ' + COALESCE(a.device_name, '') AS device_code_name
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
FROM m_device a FROM m_device a
LEFT JOIN m_brands b ON a.brand_id = b.brand_id LEFT JOIN m_brands b ON a.brand_id = b.brand_id
WHERE a.device_id = $1 AND a.deleted_at IS NULL WHERE a.device_id = $1 AND a.deleted_at IS NULL