insert post data into mongoDB using Node
<p>I am very new to node JS and mongo.</p>

<p>I am working on a personal website that stores a user's information in my database.</p>

<p>For simplicity, let's say I have the following form in jade...</p>

<pre><code>form(class="inputs", action="/login", method="post")
    input(type="text", name="email",class="form-control", id="emailLogin", placeholder="Queen's Email")
</code></pre>

<p>I already set up a database, and I was able to connect to it using the following javascript...</p>

<pre><code>var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/user');
var db = mongoose.connection;

db.on('error', console.error);
db.once('open', function() {
    // Create your schemas and models here.
});
</code></pre>

<p>I want to store the input from <code>email</code> for every user that registers using the form above. </p>

<p>I am guessing I would first have to create a schema, which would probably look like this, but I'm not sure...</p>

<pre><code>var Schema = mongoose.Schema;

var userSchema = new Schema({
    email: String
});
//I think I have to create a model too?
</code></pre>

<p>And to get POST data I think I would need some code that looks like this...</p>

<pre><code>app.post('/login', function(request, response){
//I am not sure what to put inside
});
</code></pre>

<p>My question is, can someone show me how to implement all these together so that every time a user registers with their email, it is saved in the database. It is very hard to research this, and have tried and failed many times.</p>

<p><strong>EDIT</strong></p>

<p>Here is my <code>index.js</code> file...</p>

<pre><code>var express = require('express');
var router = express.Router();

/* GET home page. */
router.get('/', function(req, res, next) {
  res.render('index', { title: 'QChat' });
});

module.exports = router;
</code></pre>

<p>Also, here is another file in my <code>routes</code> directory called <code>users.js</code>, I'm not sure what its purpose is...</p>

<pre><code>var express = require('express');
var router = express.Router();

/* GET users listing. */
router.get('/', function(req, res, next) {
  res.send('respond with a resource');
});

module.exports = router;
</code></pre>