reinitializing codebase and resuming development

This commit is contained in:
Shibi Chakkaravarthy
2026-09-27 00:48:18 +05:30
parent 5e894627f5
commit be7211ac28
23 changed files with 744 additions and 45 deletions
+72 -2
View File
@@ -20,7 +20,7 @@ import { getLocationsByQuery } from "../models/Location/operations.js";
import dayjs from "dayjs";
import { ObjectId } from "mongodb";
export const createAccessController = async (req, res) => {
export const createAccessController = async (req, res, next) => {
try {
const { user } = res.locals;
const { employee, designation, department, branch, role } = req.body;
@@ -35,7 +35,8 @@ export const createAccessController = async (req, res) => {
});
res.status(200).json({ result: access });
} catch (error) {
res.status(500).json({ error: error.message });
console.log("createAccessController Error", error);
next(error);
}
};
@@ -203,6 +204,74 @@ export const getAllEmployeeController = async (req, res, next) => {
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: "assignments",
localField: "_id",
foreignField: "user",
as: "assignments",
pipeline: [
{
$match: {
isActive: true,
},
},
],
},
},
{
$unwind: {
path: "$assignments",
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: "venues",
localField: "assignments.venue",
foreignField: "_id",
as: "assignments.venue",
},
},
{
$unwind: {
path: "$assignments.venue",
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: "partners",
localField: "assignments.venue.entity",
foreignField: "_id",
as: "assignments.venue.entity",
},
},
{
$unwind: {
path: "$assignments.venue.entity",
preserveNullAndEmptyArrays: true,
},
},
// {
// $unwind: {
// path: "$assignedVenues",
// preserveNullAndEmptyArrays: true,
// },
// },
{
$group: {
_id: "$_id",
name: { $first: "$name" },
id: { $first: "$id" },
profile: { $first: "$profile" },
designation: { $first: "$designation" },
department: { $first: "$department" },
assignments: {
$push: "$assignments",
},
},
},
{
$project: {
_id: 1,
@@ -211,6 +280,7 @@ export const getAllEmployeeController = async (req, res, next) => {
profile: 1,
designation: "$designation.name",
department: "$department.name",
assignments: 1,
},
},
];