working on delete bores

master
varun 3 years ago
parent f6a6974b78
commit 03ed41c7a9

@ -220,3 +220,33 @@ exports.addBores = async (req, reply) => {
throw boom.boomify(err); throw boom.boomify(err);
} }
}; };
exports.getBores = async (req, reply) => {
try {
await Bore.find({customerId: req.query.customerId})
.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.deleteBoreInfo = async (req, reply) => {
try {
var customerId = req.params.customerId;
var boreName = req.query.boreName;
const Bore = await Tanker.findOneAndDelete({ boreName: boreName,customerId:customerId });
reply.send({ status_code: 200, data: Bore});
// return tanker;
} catch (err) {
throw boom.boomify(err);
}
};

@ -201,6 +201,55 @@ module.exports = function (fastify, opts, next) {
//onResponse: validationHandler.sendPhoneVerificationCode, //onResponse: validationHandler.sendPhoneVerificationCode,
}); });
fastify.get("/api/getBores", {
schema: {
tags: ["Supplier"],
description: "This is for Get Bore Data",
summary: "This is for to Get Bore Data",
querystring: {
customerId: {type: 'string'}
},
security: [
{
basicAuth: [],
},
],
},
preHandler: fastify.auth([fastify.authenticate]),
handler: tankersController.getBores,
});
fastify.route({
method: "PUT",
url: "/api/deleteBore/:customerId",
schema: {
tags: ["Supplier"],
summary: "This is for delete bore",
params: {
required: ["customerId"],
type: "object",
properties: {
customerId: {
type: "string",
description: "customerId",
},
},
},
querystring: {
boreName: {type: 'string'}
},
security: [
{
basicAuth: [],
},
],
},
preHandler: fastify.auth([fastify.authenticate]),
handler: tankersController.deleteBoreInfo,
});

Loading…
Cancel
Save