pricing update backend

This commit is contained in:
Priyatham Sai Chand 2021-03-20 16:56:05 +05:30
parent 6d0e02cbb4
commit 98fc91e797
1 changed files with 23 additions and 0 deletions

View File

@ -109,5 +109,28 @@ router.get("/", auth, async (req, res) => {
id: user._id,
});
});
router.put("/update", async (req, res) => {
const { email,pricing } = req.body;
const existingUser = await User.findOne({ email: email });
if (!existingUser) {
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) => {
res.send(user);
})
})
})
module.exports = router;