100xdevs-cohort-2 / paytm

144 stars 334 forks source link

Fixed the filter condition in the PUT route for User collection #3

Open harshashetty67 opened 5 months ago

harshashetty67 commented 5 months ago

The filter condition (shown below) used to update User collection in PUT route handler was giving '"Updated successfully" response but under the hood it was not updating the respective record in the MongoDB.

await User.findOneAndUpdate(req.body, {
    id: req.userId
  });

There is a small typo in the filter id we are passing, it should be _id.

Solution : The filter condition should be modified as shown below :

await User.findOneAndUpdate(req.body, {
    _id: req.userId
  });

P.S : I know it's a simple fix 👍, but felt like pointing out if you are worrying like me why records didn't update in MongoDB

rohithreddy009 commented 5 months ago

can you tell how did you made pr to the subbranch of this repo.

harshashetty67 commented 5 months ago

can you tell how did you made pr to the subbranch of this repo.

While forking, uncheck the check-box (that only forks main/master branch) as shown in below snap then it will copy all branches. From there you can edit code and raise PR to sub-branches.

image

rohithreddy009 commented 5 months ago

Got it! thanks