diff --git a/controllers/assignment.controller.js b/controllers/assignment.controller.js index 509fe4e..d2555db 100644 --- a/controllers/assignment.controller.js +++ b/controllers/assignment.controller.js @@ -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) { res.status(500).json({ message: "Error getting assignment", error }); } diff --git a/models/Location/model.js b/models/Location/model.js index 04dfabc..358e6d6 100644 --- a/models/Location/model.js +++ b/models/Location/model.js @@ -7,6 +7,11 @@ const geofenceSchema = new Schema({ required: false, ref: "venue", }, + assignment: { + type: Types.ObjectId, + required: false, + ref: "assignment", + }, action: { type: String, required: false, diff --git a/routes/assignment.route.js b/routes/assignment.route.js index 4641806..26e0239 100644 --- a/routes/assignment.route.js +++ b/routes/assignment.route.js @@ -13,7 +13,7 @@ const router = new Router(); router.post("/", authorize("assignment", "write"), createAssignmentHandler); router.patch("/:id", authorize("assignment", "write"), updateAssignmentHandler); -router.patch("/:id", authorize("assignment", "read"), getAssignmentByIdHandler); +router.get("/:id", authorize("assignment", "read"), getAssignmentByIdHandler); router.get( "/user/:id", authorize("assignment", "read"),