title: How do I properly embed documents in mongoose?
body: <pre class="lang-javascript prettyprint-override"><code>var mongoose = require('mongoose');
  
  var Schema = mongoose.Schema;
  var ObjectId = Schema.ObjectId;
  
  var Comment = mongoose.model('Comment', new Schema({
      title     : String,
      body      : String,
      date      : Date
  }))
  
  var Post = mongoose.model('Post', new Schema({
      comments  : [Comment]
  }))
  
  module.exports.Comment = Comment
  module.exports.Post = Post
  </code></pre>
  <p>Followed a tutorial for a simple app, and while trying to create something else off of it and learning about Mongoose schemas I get an error trying to use embedded documents with the way the previous app defined models</p>
  <p>I'm getting this error</p>
  <blockquote>
  <p>throw new TypeError('Undefined type <code>' + name + '</code> at array `' + path
  +</p>
  </blockquote>
  <p>TypeError: Undefined type <code>model</code> at array <code>comments</code></p>