made changes in add , update and delete tanks

master
varun 3 years ago
parent eed250be99
commit 78d7f32116

@ -63,12 +63,14 @@ console.log(req.params);
//update selected tank //update selected tank
exports.updateTanksInfo = async (req, reply) => { exports.updateTanksInfo = async (req, reply) => {
try { try {
//const username = loginObject.user.username; const username = loginObject.user.username;
const tankName = req.params.tankName; const tankName = req.params.tankName;
const tank = req.body; const tank = req.body;
const { ...updateData } = tank; const { ...updateData } = tank;
const update = await Tank.findOneAndUpdate({ tankName: tankName, }, updateData, { new: true }); const update = await Tank.findOneAndUpdate({ tankName: tankName,userName:username, }, updateData, { new: true });
console.log(update.username)
//return update; //return update;
reply.send({ status_code: 200, data: update }); reply.send({ status_code: 200, data: update });
@ -83,8 +85,9 @@ exports.updateTanksInfo = async (req, reply) => {
//delete selected tank //delete selected tank
exports.deleteTanksInfo = async (req, reply) => { exports.deleteTanksInfo = async (req, reply) => {
try { try {
const username = loginObject.user.username;
const tankName = req.params.tankName; const tankName = req.params.tankName;
const tank = await Tank.findOneAndDelete({ tankName: tankName }); const tank = await Tank.findOneAndDelete({ tankName: tankName,userName:username });
reply.send({ status_code: 200, data: tank}); reply.send({ status_code: 200, data: tank});
// return tank; // return tank;

Loading…
Cancel
Save