wisdom #2

Merged
yogiedigital merged 126 commits from wisdom into main 2025-10-20 03:26:33 +00:00
Showing only changes of commit 373caf307b - Show all commits

View File

@@ -12,6 +12,25 @@ const getAllDevicesDb = async () => {
return result.recordset;
};
// Search devices by keyword
const searchDevicesDb = async (keyword) => {
const queryText = `
SELECT *
FROM m_device
WHERE deleted_at IS NULL
AND (
device_name LIKE '%' + $1 + '%'
OR device_code LIKE '%' + $1 + '%'
OR device_location LIKE '%' + $1 + '%'
OR ip_address LIKE '%' + $1 + '%'
OR device_description LIKE '%' + $1 + '%'
)
ORDER BY device_id ASC
`;
const result = await pool.query(queryText, [keyword]);
return result.recordset;
};
// Get device by ID
const getDeviceByIdDb = async (id) => {
const queryText = `
@@ -73,4 +92,5 @@ module.exports = {
createDeviceDb,
updateDeviceDb,
softDeleteDeviceDb,
searchDevicesDb,
};