feat: added get area, rows & bays by zone, area, row id apis

This commit is contained in:
Sathishkumar Krishnan
2022-02-09 19:22:02 +05:30
parent 6657c51fd2
commit 12d675f14d
6 changed files with 75 additions and 0 deletions

View File

@@ -102,4 +102,24 @@ module.exports = {
next(error);
}
},
getZoneAreasByID: async (req, res, next) => {
const { id } = req.params;
if (!id) {
res.status(400).send({ success: false, message: "Missing id param" });
return;
}
try {
const zoneData = await Zone.findById(id).populate("areas");
if (!zoneData) {
res.status(404).send({ success: false, message: "not found" });
return;
}
res.send({ success: true, data: zoneData.areas });
} catch (error) {
next(error);
}
},
};