|
|
|
@ -645,14 +645,18 @@ exports.addDepartment = async (request, reply) => {
|
|
|
|
|
{
|
|
|
|
|
$group: {
|
|
|
|
|
_id: "$zone", // Group by zone
|
|
|
|
|
locations: { $addToSet: { $toUpper: "$location" } }, // Collect unique locations in uppercase
|
|
|
|
|
locations: {
|
|
|
|
|
$addToSet: {
|
|
|
|
|
$toUpper: { $trim: { input: "$location" } } // Convert to uppercase and trim whitespace
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
$project: {
|
|
|
|
|
_id: 0, // Exclude the _id field
|
|
|
|
|
zone: "$_id", // Include zone
|
|
|
|
|
locations: 1 // Just return the locations field as is
|
|
|
|
|
locations: 1 // Return locations
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
]);
|
|
|
|
@ -662,8 +666,7 @@ exports.addDepartment = async (request, reply) => {
|
|
|
|
|
console.error(err);
|
|
|
|
|
throw new Error("Error fetching locations.");
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|