master^2
Bhaskar 9 months ago
parent 56ee1db55b
commit c34c3b41c9

@ -645,14 +645,18 @@ exports.addDepartment = async (request, reply) => {
{ {
$group: { $group: {
_id: "$zone", // Group by zone _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: { $project: {
_id: 0, // Exclude the _id field _id: 0, // Exclude the _id field
zone: "$_id", // Include zone zone: "$_id", // Include zone
locations: 1 // Just return the locations field as is locations: 1 // Return locations
}, },
}, },
]); ]);
@ -666,7 +670,6 @@ exports.addDepartment = async (request, reply) => {
exports.getLocationsByZone = async (req, reply) => { exports.getLocationsByZone = async (req, reply) => {
try { try {
const { zone } = req.params; // Get zone from path params const { zone } = req.params; // Get zone from path params

Loading…
Cancel
Save