title: Mongoose findByIdAndUpdate - not updating selection
body: <p>I'm following a tutorial with MERN (source code here: <a href="https://github.com/Nikhilthadani/Book-Store-With-MERN-Stack/blob/Backend/controllers/books-controller.js" rel="nofollow noreferrer">https://github.com/Nikhilthadani/Book-Store-With-MERN-Stack/blob/Backend/controllers/books-controller.js</a>)</p>
  <p>Everything seems fine with the initial routing (get &amp; post) , until we added a route for updating entries (PUT) in mongoDB.</p>
  <p>Here is my function for the PUT</p>
  <pre><code>//book-controller.js
  
  const updateBook = async (req, res, next) =&gt; {
      const id = req.params.id;
      const { name, code } = req.body;
      let book;
      try {
        book = await Book.findByIdAndUpdate(id, {new: true}, {
          name,
          code,
        });
        book = await book.save();
      } catch (err) {
        console.log(err);
      }
      if (!book) {
        return res.status(404).json({ message: &quot;Unable To Update By this ID&quot; });
      }
      return res.status(200).json({ book });
    };
  </code></pre>
  <p>Here is my Schema</p>
  <pre><code>// Book.js
  
  const mongoose = require('mongoose')
  const bookSchema = new mongoose.Schema({
      name: {
          type: String,
          required: true,
      },
      code: {
          type: Number,
          required: true,
      },
  });
  
  module.exports = mongoose.model(&quot;Book&quot;, bookSchema);
  </code></pre>
  <p>When I try to test this function in Postman, the GET request returns the entry that I'm attempting to update just fine.</p>
  <p>Confirming database entry with Get:</p>
  <p><a href="https://i.stack.imgur.com/jEL46.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jEL46.png" alt="Confirming database entry with Get" /></a></p>
  <p>However after testing PUT the particular entry I'm trying to update will remain unchanged, despite no output errors.</p>
  <p>Testing PUT with Postman:</p>
  <p><a href="https://i.stack.imgur.com/0dXCp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0dXCp.png" alt="Testing PUT with Postman" /></a></p>