location update with separate data structure for geofence events

This commit is contained in:
Shibi Chakkaravarthy
2026-06-16 00:56:15 +05:30
parent 36e1bf664f
commit 3ae41a8cd5
5 changed files with 158 additions and 5 deletions
+48
View File
@@ -98,3 +98,51 @@ export const getAssignmentByVenueHandler = async (req, res) => {
res.status(500).json({ message: "Error getting assignment", error });
}
};
export const getAssignmentByIdHandler = async (req, res) => {
try {
const { id } = req.params;
const pipeline = [
{
$match: {
_id: ObjectId.createFromHexString(id),
},
},
{
$lookup: {
from: "venues",
localField: "venue",
foreignField: "_id",
as: "venue",
},
},
{
$unwind: {
path: "$venue",
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: "partners",
localField: "venue.entity",
foreignField: "_id",
as: "partner",
},
},
{
$unwind: {
path: "$partner",
preserveNullAndEmptyArrays: true,
},
},
];
const assignment = await aggregateAssignment(pipeline)[0];
res.status(200).json({ result: assignment });
} catch (error) {
res.status(500).json({ message: "Error getting assignment", error });
}
};