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) => { exports.getallCompanyNames = async (req, reply) => {
// try { try {
// await City.find() await City.find()
// .exec() .select("officeName -_id") // Select only officeName and exclude _id
// .then((docs) => { .exec()
// reply.send({ status_code: 200, data: docs, count: docs.length }); .then((docs) => {
// }) const officeNames = docs.map((doc) => doc.officeName); // Extract only officeName values
// .catch((err) => { reply.send({ status_code: 200, data: officeNames, count: officeNames.length });
// console.log(err); })
// reply.send({ error: err }); .catch((err) => {
// }); console.log(err);
// } catch (err) { reply.send({ error: err });
// throw boom.boomify(err); });
// } } catch (err) {
// }; throw boom.boomify(err);
}
};
// exports.getAllDepartmentsParticularFields = async (req, reply) => { // exports.getAllDepartmentsParticularFields = async (req, reply) => {

@ -96,6 +96,23 @@ module.exports = function (fastify, opts, next) {
// handler: departmentController.getAllDepartmentsParticularFields, // 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", { fastify.delete("/api/deletecity/:cityId", {
schema: { schema: {
description: "Delete a city by cityId", description: "Delete a city by cityId",

Loading…
Cancel
Save