From 42598d6f205448a0f48b490785417e697cd54f28 Mon Sep 17 00:00:00 2001 From: Priyatham-sai-chand Date: Wed, 24 Mar 2021 08:35:53 +0530 Subject: [PATCH] pricing update to db --- routes/users.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/routes/users.js b/routes/users.js index fd98d44..13bdb51 100644 --- a/routes/users.js +++ b/routes/users.js @@ -111,22 +111,22 @@ router.get("/", auth, async (req, res) => { }); }); router.put("/update", async (req, res) => { - const { email,pricing } = req.body; - const existingUser = await User.findOne({ email: email }); + const { id,pricing } = req.body; - - if (!existingUser) { + console.log("id " + id) + if (!id) { return res.status(400).json({ Msg: "Not all fields have been entered." }); } - User.findByIdAndUpdate({ _id: existingUser._id }, { pricing: pricing }).then(() => { - User.findOne({ email: email }).then((user) => { + User.findByIdAndUpdate(id, { pricing: pricing }).then(() => { + User.findOne({ _id: id }).then((user) => { res.send(user); + console.log(user) }) }) - +