From c3f6acb8b13769c1215315681f89c9d1c76b76be Mon Sep 17 00:00:00 2001 From: Hitansh Doshi Date: Sun, 9 Jul 2023 19:52:25 +0530 Subject: [PATCH] added update infrastructure to apidoc --- _apidoc.js | 18 ++++++++++++++++++ controller/accreditation.js | 10 +++++++--- services/accreditation.js | 4 ++-- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/_apidoc.js b/_apidoc.js index c91ac79..3137339 100644 --- a/_apidoc.js +++ b/_apidoc.js @@ -191,6 +191,24 @@ * * */ +/** + * @api {post} /infrastructure/update Update infrastructure details + * @apiName UpdateInfrastructure + * @apiGroup Infrastructure + * @apiDescription update Existing Infrastructure details + * + * @apiBody {String} id Id of the infrastructure to be updated + * @apiBody {String} [name] The name of the infrastructure. + * @apiBody {String} [type] The type of the infrastructure. + * @apiBody {String} [wing] The wing where the infrastructure is located. + * @apiBody {Number} [floor] The floor where the infrastructure is located. + * @apiBody {Number} [capacity] The capacity of the infrastructure. + * + * @apiSuccess {String} res infrastructure updated. + * @apiError (Error 500) err Error in updating database + * + */ + // ------------------------------------------------------------------------------------------ // Accreditation. // ------------------------------------------------------------------------------------------ diff --git a/controller/accreditation.js b/controller/accreditation.js index 2d2be61..2ffbbc9 100644 --- a/controller/accreditation.js +++ b/controller/accreditation.js @@ -1,4 +1,6 @@ -import { addNewAccreditation, deleteAccreditationById, updateAccreditationById, getAccreditations } from "#services/accreditation"; +import { + addNewAccreditation, deleteAccreditationById, updateAccreditationById, getAccreditations, +} from "#services/accreditation"; import { logger } from "#util"; async function addAccreditation(req, res) { @@ -31,7 +33,7 @@ async function updateAccreditation(req, res) { const { id, ...data } = req.body; - + try { await updateAccreditationById(id, data); res.json({ res: "accreditation updated" }); @@ -53,4 +55,6 @@ async function showAccreditation(req, res) { } } -export default { addAccreditation, updateAccreditation, deleteAccreditation, showAccreditation }; +export default { + addAccreditation, updateAccreditation, deleteAccreditation, showAccreditation, +}; diff --git a/services/accreditation.js b/services/accreditation.js index 1411e7e..0f93378 100644 --- a/services/accreditation.js +++ b/services/accreditation.js @@ -23,7 +23,7 @@ export async function getAccreditations(filter) { } export async function deleteAccreditationById(accredationId) { - const deleted = await accreditation.remove({ _id: accredationId }); + const deleted = await Accreditation.remove({ _id: accredationId }); if (deleted) { return deleted; } @@ -31,7 +31,7 @@ export async function deleteAccreditationById(accredationId) { } export async function updateAccreditationById(id, data) { - const updated = await accreditation.update({ _id: id }, data); + const updated = await Accreditation.update({ _id: id }, data); if (updated) { return updated; }