geofence model changes to include assignment property

This commit is contained in:
Shibi Chakkaravarthy
2026-06-16 06:07:29 +05:30
parent 3ae41a8cd5
commit 5e894627f5
3 changed files with 10 additions and 3 deletions
+4 -2
View File
@@ -139,9 +139,11 @@ export const getAssignmentByIdHandler = async (req, res) => {
}, },
]; ];
const assignment = await aggregateAssignment(pipeline)[0]; const assignment = await aggregateAssignment(pipeline);
res.status(200).json({ result: assignment }); console.log("ASSIGNMENT", assignment);
res.status(200).json({ result: assignment[0] });
} catch (error) { } catch (error) {
res.status(500).json({ message: "Error getting assignment", error }); res.status(500).json({ message: "Error getting assignment", error });
} }
+5
View File
@@ -7,6 +7,11 @@ const geofenceSchema = new Schema({
required: false, required: false,
ref: "venue", ref: "venue",
}, },
assignment: {
type: Types.ObjectId,
required: false,
ref: "assignment",
},
action: { action: {
type: String, type: String,
required: false, required: false,
+1 -1
View File
@@ -13,7 +13,7 @@ const router = new Router();
router.post("/", authorize("assignment", "write"), createAssignmentHandler); router.post("/", authorize("assignment", "write"), createAssignmentHandler);
router.patch("/:id", authorize("assignment", "write"), updateAssignmentHandler); router.patch("/:id", authorize("assignment", "write"), updateAssignmentHandler);
router.patch("/:id", authorize("assignment", "read"), getAssignmentByIdHandler); router.get("/:id", authorize("assignment", "read"), getAssignmentByIdHandler);
router.get( router.get(
"/user/:id", "/user/:id",
authorize("assignment", "read"), authorize("assignment", "read"),