title: findByIdAndUpdate Model and increment based off button click
body: <p>I am simply trying to increment a Mongoose User model every time a button gets clicked in my dashboard.ejs and am running into trouble.  This is my first time creating express routes so any help would be great!</p>
  <p>You can view the terminal error below.  I am only showing the method in the controller which I am working on right now, but the conrtoller file is actually much larger.</p>
  <p>the req.user object is returning properly in the controller and returns the current user that is logged in</p>
  <h2>userRoutes.js</h2>
  <pre><code>var express = require('express');
  var router = express.Router();
  const controller = require('./userController');
  
  
  
  router.route('/login')
    .get(controller.getLogin)
    .post(controller.postLogin)
  
  router.route('/register')
    .get(controller.getRegister)
    .post(controller.postRegister)
  router.route('/logout')
    .get(controller.getLogout)
  
  router.route('/buyBullet')
    .get(controller.buyBullet);
  
  
  module.exports = router;
  </code></pre>
  <h2>userController.js</h2>
  <pre><code>exports.buyBullet = (req, res, next) =&gt; {
  
    User.findByIdAndUpdate(req.user._id, { $inc: { bullets: 1 }})
    User.save();
    console.log(req.user)
    res.redirect('/dashboard');
  
  }
  </code></pre>
  <h2>dashboard.ejs</h2>
  <pre><code>&lt;%- include('partials/header'); %&gt;
  &lt;a href=&quot;/users/logout&quot; class=&quot;btn btn-secondary&quot;&gt;Logout&lt;/a&gt;
  &lt;a href=&quot;/users/buyBullet&quot; class=&quot;btn btn-warning&quot;&gt;Buy Bullet&lt;/a&gt;
  &lt;div class=&quot;container&quot;&gt;
    &lt;div class=&quot;col-md-8 m-auto&quot;&gt;
      &lt;ul class=&quot;nav justify-content-center mt-5 mb-5&quot;&gt;
        &lt;li class=&quot;nav-item&quot;&gt;
          &lt;a class=&quot;nav-link&quot;href=&quot;#&quot;&gt;Make Your Pick&lt;/a&gt;
        &lt;/li&gt;
        &lt;li class=&quot;nav-item&quot;&gt;
          &lt;a class=&quot;nav-link&quot;href=&quot;#&quot;&gt;Dashboard&lt;/a&gt;
        &lt;/li&gt;
        &lt;li class=&quot;nav-item&quot;&gt;
          &lt;a class=&quot;nav-link&quot;href=&quot;https://www.nfl.com/schedules/&quot; target=&quot;_blank&quot;&gt;Schedule&lt;/a&gt;
        &lt;/li&gt;
        &lt;li class=&quot;nav-item&quot;&gt;
          &lt;a class=&quot;nav-link&quot;href=&quot;#&quot;&gt;Rules&lt;/a&gt;
        &lt;/li&gt;
        &lt;li class=&quot;nav-item&quot;&gt;
          &lt;a class=&quot;nav-link&quot;href=&quot;#&quot;&gt;Message Board&lt;/a&gt;
        &lt;/li&gt;
      &lt;/ul&gt;
    &lt;/div&gt;
    &lt;div class=&quot;col-md-6 m-auto&quot;&gt;
      &lt;div class=&quot;card card-body&quot;&gt;
        &lt;h1 class=&quot;text-center mb-3&quot;&gt;Dashboard&lt;/h1&gt;
        &lt;p&gt;The Date is now &lt;b&gt;&lt;%= new Intl.DateTimeFormat('en-GB', { year: 'numeric', month: 'long', day: '2-digit'}).format(new Date()) %&gt;&lt;/b&gt; 
          and the time is now &lt;b&gt;&lt;%= new Date().toLocaleTimeString() %&gt;&lt;/b&gt;&lt;/p&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    
  &lt;/div&gt;
  </code></pre>
  <h2>error</h2>
  <pre><code>Error: Failed to lookup view &quot;error&quot; in views directory &quot;/Users/jojovera/Documents/fantasyfootball/views&quot;
      at Function.render (/Users/jojovera/Documents/fantasyfootball/node_modules/express/lib/application.js:580:17)
      at ServerResponse.render (/Users/jojovera/Documents/fantasyfootball/node_modules/express/lib/response.js:1008:7)
      at ServerResponse.res.render (/Users/jojovera/Documents/fantasyfootball/node_modules/express-ejs-layouts/lib/express-layouts.js:77:18)
      at /Users/jojovera/Documents/fantasyfootball/app.js:74:7
      at Layer.handle_error (/Users/jojovera/Documents/fantasyfootball/node_modules/express/lib/router/layer.js:71:5)
      at trim_prefix (/Users/jojovera/Documents/fantasyfootball/node_modules/express/lib/router/index.js:315:13)
      at /Users/jojovera/Documents/fantasyfootball/node_modules/express/lib/router/index.js:284:7
      at Function.process_params (/Users/jojovera/Documents/fantasyfootball/node_modules/express/lib/router/index.js:335:12)
      at next (/Users/jojovera/Documents/fantasyfootball/node_modules/express/lib/router/index.js:275:10)
      at Layer.handle_error (/Users/jojovera/Documents/fantasyfootball/node_modules/express/lib/router/layer.js:67:12)
      at trim_prefix (/Users/jojovera/Documents/fantasyfootball/node_modules/express/lib/router/index.js:315:13)
      at /Users/jojovera/Documents/fantasyfootball/node_modules/express/lib/router/index.js:284:7
      at Function.process_params (/Users/jojovera/Documents/fantasyfootball/node_modules/express/lib/router/index.js:335:12)
      at next (/Users/jojovera/Documents/fantasyfootball/node_modules/express/lib/router/index.js:275:10)
      at Layer.handle_error (/Users/jojovera/Documents/fantasyfootball/node_modules/express/lib/router/layer.js:67:12)
      at trim_prefix (/Users/jojovera/Documents/fantasyfootball/node_modules/express/lib/router/index.js:315:13)
  GET /users/buyBullet 500 60.356 ms - 2220
  </code></pre>