Implementation of nodejs Project comment function

encountered a problem when trying to tamper with a forum with express+mongoose to implement the comment function.

model: of the post

const ArticleSchema = new Schema({
  author: { type: Schema.Types.ObjectId, ref: "User" },
  createTime: { type: Date },
  thumb: [{ type: Schema.Types.ObjectId, ref: "User" }],
  comment: [{ type: Schema.Types.ObjectId, ref: "Comment" }],
  text: String
});

model: of comments

const CommentSchema = new Schema({
  text: String,
  createTime: { type: Date },
  poster: { type: Schema.Types.ObjectId, ref: "User" },
  posts: {type: Schema.Types.ObjectId, ref: "Article"}
})

render data:

  Article.find()
    .sort("-createTime")
    .populate("author")
    .populate("comment")
    .exec((err, articles) => {
      if (err) return next(err)
      res.render("container/index", {
        title: "xxxx",
        articles
      })
    })

Front end:

:comments[i].text
: comments[i].poster

can get the content of the comment, but the reviewer displays the value of _ id, in which case should I query User again?

Mar.14,2021

deep-populate

User.
  findOne({ name: 'Val' }).
  populate({
    path: 'friends',
    // Get friends of friends - populate the 'friends' array for every friend
    populate: { path: 'friends' }
  });

use the aggregate query .aggregate , or you can check it again.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b305f8-2bd06.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b305f8-2bd06.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?