title: How to register and call a schema in mongoose
body: <p>I created schema for my file and calling it as below but it says error that schema is not registered for comments........Is this due to path?</p>
  
  <p>My schema,</p>
  
  <pre><code>var mongoose = require('mongoose'),
    path = require('path'),
    config = require(path.resolve('./config/config')),
    Schema = mongoose.Schema;
  
  var Commentsscheme = new Schema({
    articleid: {
      type: Schema.ObjectId
    },
    fromuser: {
      type: String
    },
    touser: {
      type: String
    },
    comment: {
      type: String
    }
  });
  
  mongoose.model('comments', Commentsscheme);
  </code></pre>
  
  <p>My js,</p>
  
  <pre><code>   var path = require('path'),
    mongoose = require('mongoose'),
    passport = require('passport'),
    Comments = mongoose.model('comments');
  
  /* ------ Inserting a comment  ------ */
  exports.insertcomment = function (req, res) {
    var comments = new Comments(req.body);
    console.log(comments)
    comments.status = 1;
    var data = {};
    comments.save(function (err,resl) {
      if (err) {
        console.log(err);
        return err;
      } 
       data = { status: false, error_code: 0, message: 'Unable to insert' };
      if (resl) {
        data = { status: true, error_code: 0,result: resl, message: 'Inserted successfully' };
      }
        res.json(data);
    });
  };
  </code></pre>
  
  <p>I created schema for my file and calling it as below but it says error that schema is not registered for comments........can any one please suggest help,........................</p>