title: How to save Data in MongoDB from forms
body: <p>I have a form. I need to get text from my form to save it in MongoDB.</p>
  
  <p>tweets.ejs: </p>
  
  <pre><code>&lt;form method="post" action="/tweets"&gt;
  &lt;input type="text" id="txt" name="text"/&gt;
  &lt;input type="button" id="btn" value="Touch me"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Here is my route file tweets.js:</p>
  
  <pre><code>var Message = require('models/messages');
  exports.get = function(req,res) {
      res.render('tweets')
  };
  </code></pre>
  
  <p>I use mongoose schema(models/messages.js):</p>
  
  <pre><code>var mongoose = require('../libs/mongoose'),
      Schema = mongoose.Schema;
  var MessageSchema = new Schema({
      message: String,
      date: Date
  });
  var Message = mongoose.model('Message', MessageSchema);
  module.exports = Message;
  </code></pre>
  
  <p>I tried set var m = req.body.text in tweets.js, but I think it's absolutely wrong way</p>
  
  <pre><code>exports.post = function(req,res){
      var m = new Message;
      m.message = req.body.text;
      m.save(); }
  </code></pre>
  
  <p>Explain me how to do it right please!</p>