Operational Endpoints for Admin, Products, Assignments, Location, Vendor, Venue completed. Geofence Testing PEnding
This commit is contained in:
@@ -3,6 +3,8 @@ import {
|
||||
getLocationByQuery,
|
||||
getLocationByRadius,
|
||||
} from "../models/Location/operations";
|
||||
import { aggregateAssignment } from "../models/Assignment/operations";
|
||||
import { ObjectId } from "mongodb";
|
||||
|
||||
/*
|
||||
Sample Location Payload
|
||||
@@ -69,3 +71,48 @@ export const getLocationController = async (req, res) => {
|
||||
res.status(500).json({ error: error.message });
|
||||
}
|
||||
};
|
||||
|
||||
export const getMyAssignedVenuesHandler = async (req, res, next) => {
|
||||
try {
|
||||
const { user } = res.locals;
|
||||
const pipeline = [
|
||||
{
|
||||
$match: {
|
||||
user: ObjectId?.createFromHexString(user.id),
|
||||
isActive: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "venues",
|
||||
localField: "venue",
|
||||
foreignField: "_id",
|
||||
as: "venue",
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: "$venue",
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "partners",
|
||||
localField: "venue.entity",
|
||||
foreignField: "_id",
|
||||
as: "partner",
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: "$partner",
|
||||
},
|
||||
},
|
||||
];
|
||||
const assignment = await aggregateAssignment(pipeline);
|
||||
res.status(200).json({ result: assignment });
|
||||
} catch (error) {
|
||||
console.log("getMyAssignedVenuesHandler Error", error);
|
||||
next(error);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user