MongoDB does a comment system, how to design the structure of the data table?

the general comment system goes like this:

comments on articles-> comments on articles-> comments on comments. Using mysql, there are two tables, articles and comments. Comments on articles and comments on comments are stored in one table, comments.

question:
so how do you design the data table structure to do the same thing with mongodb?

Mar.30,2021

mongo is a good place to do such a thing, with a comment structure at the bottom of the article.

general structure:

{
    title: String,
    content: String,
    createTime: DateTime,
    comments: [
        userName: String,
        // JSON(
        content: String 
    ] 
}

but it depends on the demand.

    Whether the
  1. comment appears as a separate concept. Such as some statistics for comments.
  2. whether comments are infinitely nested.
  3. whether comments need to be modified frequently, such as like.
Menu