get all company names based on city schmea

master^2
Bhaskar 8 months ago
parent 5cf9fcfc4e
commit a8fdd451e8

@ -201,21 +201,24 @@ const generateDepartmentId = async (city, departmentName) => {
// }
// };
// exports.getallcities = async (req, reply) => {
// try {
// await City.find()
// .exec()
// .then((docs) => {
// reply.send({ status_code: 200, data: docs, count: docs.length });
// })
// .catch((err) => {
// console.log(err);
// reply.send({ error: err });
// });
// } catch (err) {
// throw boom.boomify(err);
// }
// };
exports.getallCompanyNames = async (req, reply) => {
try {
await City.find()
.select("officeName -_id") // Select only officeName and exclude _id
.exec()
.then((docs) => {
const officeNames = docs.map((doc) => doc.officeName); // Extract only officeName values
reply.send({ status_code: 200, data: officeNames, count: officeNames.length });
})
.catch((err) => {
console.log(err);
reply.send({ error: err });
});
} catch (err) {
throw boom.boomify(err);
}
};
// exports.getAllDepartmentsParticularFields = async (req, reply) => {

@ -96,6 +96,23 @@ module.exports = function (fastify, opts, next) {
// handler: departmentController.getAllDepartmentsParticularFields,
// });
fastify.get("/api/getallcompanyNames", {
schema: {
tags: ["Department"],
description: "This is for Get all Company Name in city schema ",
summary: "This is for to Get all Company Name in city schema ",
security: [
{
basicAuth: [],
},
],
},
//preHandler: fastify.auth([fastify.authenticate]),
handler: departmentController.getallCompanyNames,
});
fastify.delete("/api/deletecity/:cityId", {
schema: {
description: "Delete a city by cityId",

Loading…
Cancel
Save