title: How to store threaded comments using MongoDB and Mongoose for Node.js?
body: <p>What would be the best way to store comments trees in MongoDB and Mongoose? Currently I have this:</p>
  
  <pre><code>CommentableSchema = new Schema({
      ...
  });
  
  ReplySchema = new Schema({
      userId: Number,
      'body': String,
      createdAt: Date,
      updatedAt: Date
  });
  
  CommentSchema = new Schema({
      commentable: CommentableSchema,
      userId: Number, // users are NOT stored in MongoDB
      subject: String,
      'body': String,
      createdAt: Date,
      updatedAt: Date,
      replies: [ReplySchema],
      length: Number // comment + all replies
  });
  </code></pre>
  
  <p>But this seems to be suitable only for top level comment + 1 more level of comments. I am fairly certain that I can not use <code>ReplySchema</code> inside <code>ReplySchema</code>. </p>