Node.js reddit评论系统如何在mongodb/nodejs中复制

Node.js reddit评论系统如何在mongodb/nodejs中复制,node.js,mongodb,mongoose,Node.js,Mongodb,Mongoose,如何在MongoDB/mongoose中创建嵌套的注释回复,以创建类似reddit嵌套的注释系统。以下是我迄今为止创建的模式: var CommentSchema = Schema({ body: {type: String}, chapterId: {type: RK, ref: 'Chapter'}, by: {type: RK, ref: 'User'}, }, {timestamps: true}); var UserSchema = new Schema({

如何在MongoDB/mongoose中创建嵌套的注释回复,以创建类似reddit嵌套的注释系统。以下是我迄今为止创建的模式:

var CommentSchema = Schema({
    body: {type: String},
    chapterId: {type: RK, ref: 'Chapter'},
    by: {type: RK, ref: 'User'},
}, {timestamps: true});

var UserSchema = new Schema({
    name: String,
    username: {type:String, unique: true},
    profile_pic: String,
  password: String,
  role:{type: [{
    type: String,
    enum: ['user', 'admin']
    }],
    default: ['user']
}
});