Unable to insert record in MongoDB
<p>Can some help me understand why I cannot insert anything into my mongoDB?</p>

<p>Here is my posting route</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>router.post('/', function(req, res, next) {

  console.log("i am posting data!");

  var MongoClient = mongodb.MongoClient;
  var url = 'mongodb://localhost:27017/blog';

  MongoClient.connect(url, function(err, db) {

    if (err) {

      console.log('Error:', err);

    } else {

      console.log('connected to db');

      var collection = db.collection('blogPost');

      var blogPost = {

        title: req.body.title,
        status: req.body.status,
        category: req.body.category,
        tags: req.body.tags,
        content: req.body.content,
        createDate: new Date()

      }

      console.log("posting data:", blogPost);

      collection.insert(blogPost, function(err, res) {

        if (err) {

          console.log('Error on Insert:', err);
        } else {

          console.log("insert successful");

        }

        db.close();
        res.render('index', {
          title: 'Welcome!!!',
          pageName: 'index'
        });

      });

    }

    db.close();

  });

});</code></pre>
</div>
</div>
</p>

<p>Here is what I am seeing in the console log.</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>GET /js/bootstrap-multiselect.js 200 16.638 ms - 66344
i am posting data!
connected to db
posting data: { title: 'test',
  status: 'A',
  category: 'excerpt',
  tags: [ 'life', 'teaching' ],
  content: 'Test from app',
  createDate: Sun Sep 04 2016 23:46:18 GMT-0600 (MDT) }
insert successful
Sun Sep 04 2016 23:46:18 GMT-0600 (MDT): Node server stopped.
/Users/bberrelez/Projects/Personal/WebApp/illcomplacent/node_modules/mongodb/lib/utils.js:98
    process.nextTick(function() { throw err; });
                                  ^

TypeError: res.render is not a function
    at /Users/bberrelez/Projects/Personal/WebApp/illcomplacent/routes/index.js:94:13
    at /Users/bberrelez/Projects/Personal/WebApp/illcomplacent/node_modules/mongodb/lib/collection.js:523:5
    at /Users/bberrelez/Projects/Personal/WebApp/illcomplacent/node_modules/mongodb/lib/collection.js:701:5
    at handleCallback (/Users/bberrelez/Projects/Personal/WebApp/illcomplacent/node_modules/mongodb/lib/utils.js:96:12)
    at executeCommands (/Users/bberrelez/Projects/Personal/WebApp/illcomplacent/node_modules/mongodb/lib/bulk/ordered.js:405:12)
    at resultHandler (/Users/bberrelez/Projects/Personal/WebApp/illcomplacent/node_modules/mongodb/lib/bulk/ordered.js:433:5)
    at /Users/bberrelez/Projects/Personal/WebApp/illcomplacent/node_modules/mongodb/node_modules/mongodb-core/lib/connection/pool.js:436:18
    at nextTickCallbackWith0Args (node.js:420:9)
    at process._tickCallback (node.js:349:13)
Brians-MacBook-Pro:illcomplacent bberrelez$ </code></pre>
</div>
</div>
</p>

<p>The thing is, it's not even inserting into the MongoDB. I can insert data just fine from the command line but, that is not what I am needing to do.  I need to insert this data from the application.</p>