小编mam*_*ood的帖子

使用 mongoose 发表评论回复架构

我想不出一种方法来创建一个合适的模式来处理帖子、评论和回复。主要停留在我将如何处理评论回复上。基本上就像reddit,他们发帖然后回复,你可以回复每个人的回复

视觉评论

在此输入图像描述

(假设他们都在带有标题的帖子页面上回复)

const CommentSchema = new mongoose.Schema({
    username: {
        type: String,
        required: true,
    },

    detail: {
        type: String,
        required: true,
    },


})


const PostSchema = new mongoose.Schema({
    author: {
        type: String,
        required: true,
    },
    title: {
        type: String,
        required: true
    },

    description: {
        type: String,
        required: true
    },
    comments: [CommentSchema]





})
Run Code Online (Sandbox Code Playgroud)

我制作的上述架构不处理对其他评论的响应。我还可以如何处理回复?

javascript mongoose mongodb express

1
推荐指数
1
解决办法
2008
查看次数

标签 统计

express ×1

javascript ×1

mongodb ×1

mongoose ×1