SHARE

Hey gang, in this REST API tutorial I’ll show you how we can update existing data in MongoDB with PUT requests.

—– COURSE LINKS:
+ Repo – https://github.com/iamshaunjp/rest-api-playlist
+ Atom editor – https://atom.io/a
+ Download GIT – https://git-scm.com/
+ Node.js for Beginners Playlist –
https://www.youtube.com/playlist?list=PL4cUxeGkcC9gcy9lrvMJ75z9maRw4byYp
+ MongoDB playlist – https://www.youtube.com/playlist?list=PL4cUxeGkcC9jpvoYriLI0bY8DOgWZfi6u

———————————————————————————————
You can find more front-end development tutorials on CSS, HTML, JavaScript, jQuery, WordPress, Node.js & more on the channel homepage…

SUBSCRIBE TO CHANNEL – https://www.youtube.com/channel/UCW5YeuERMmlnqo4oq8vwUpg?sub_confirmation=1

========== PSD to WordPress Playlist ==========

https://www.youtube.com/playlist?list=PL4cUxeGkcC9gnow7e45LQFkNVxwQ5BH-W

============ Node.js for Beginners Playlist =============

https://www.youtube.com/playlist?list=PL4cUxeGkcC9gcy9lrvMJ75z9maRw4byYp

============== The Net Ninja =====================

For more front-end development tutorials & to black-belt your coding skills, head over to – https://www.youtube.com/channel/UCW5YeuERMmlnqo4oq8vwUpg or http://thenetninja.co.uk

================== Social Links ==================

Twitter – @TheNetNinja – https://twitter.com/thenetninjauk

6 COMMENTS

  1. You can avoid the findOne call if you put a third parameter after the req.body, with { new:true } to have the new returned object updated.

  2. i get this:
    (node:4973) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1
    ): TypeError: Cannot read property 'id' of undefined
    when trying to find the updated object

  3. Hi ! Always a pleasure to see your videos !

    For the outdated version being passed as a parameter in the callback, instead of doing another db request you can pass to the mongoose function an option param which is an object { new: true }, this will pass the updated version instead of the old one as a parameter in the callback 🙂

    Please keep up your great work !

LEAVE A REPLY

Please enter your comment!
Please enter your name here