begin implementing aggregate query
This commit is contained in:
1 parent
cf3305611f
commit
247bf44406
1 file changed
+25
@@ -373,6 +373,30 @@ const getMonitorStatsById = async (req) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getHardwareDetailsById = async (req) => {
|
||||||
|
try {
|
||||||
|
const { monitorId } = req.params;
|
||||||
|
const monitor = await Monitor.findById(monitorId);
|
||||||
|
|
||||||
|
const hardwareStats = await HardwareCheck.aggregate([
|
||||||
|
{
|
||||||
|
$match: {
|
||||||
|
monitorId: monitor._id,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$facet: [],
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
return hardwareStats;
|
||||||
|
} catch (error) {
|
||||||
|
error.service = SERVICE_NAME;
|
||||||
|
error.method = "getHardwareDetailsById";
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a monitor by ID
|
* Get a monitor by ID
|
||||||
* @async
|
* @async
|
||||||
@@ -660,6 +684,7 @@ export {
|
|||||||
deleteMonitorsByUserId,
|
deleteMonitorsByUserId,
|
||||||
editMonitor,
|
editMonitor,
|
||||||
addDemoMonitors,
|
addDemoMonitors,
|
||||||
|
getHardwareDetailsById,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Helper functions
|
// Helper functions
|
||||||
|
|||||||
Reference in new issue
Block a user