pricing update to db

This commit is contained in:
Priyatham-sai-chand 2021-03-24 08:35:53 +05:30
parent 58602feaef
commit 9e90363f4c
1 changed files with 7 additions and 7 deletions

View File

@ -111,22 +111,22 @@ router.get("/", auth, async (req, res) => {
}); });
}); });
router.put("/update", async (req, res) => { router.put("/update", async (req, res) => {
const { email,pricing } = req.body; const { id,pricing } = req.body;
const existingUser = await User.findOne({ email: email });
console.log("id " + id)
if (!existingUser) { if (!id) {
return res.status(400).json({ Msg: "Not all fields have been entered." }); return res.status(400).json({ Msg: "Not all fields have been entered." });
} }
User.findByIdAndUpdate({ _id: existingUser._id }, { pricing: pricing }).then(() => { User.findByIdAndUpdate(id, { pricing: pricing }).then(() => {
User.findOne({ email: email }).then((user) => { User.findOne({ _id: id }).then((user) => {
res.send(user); res.send(user);
console.log(user)
}) })
}) })