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

时间:2017-12-08 20:26:39

标签: 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({
    name: String,
    username: {type:String, unique: true},
    profile_pic: String,
  password: String,
  role:{type: [{
    type: String,
    enum: ['user', 'admin']
    }],
    default: ['user']
}
});

0 个答案:

没有答案