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