Problems with Mongoose updating ref and populate ref

Environment:

  • Mongodb 3.6.3
  • mongoose: 5.2.5
  • nodeJS: 8.x

description:

  • simulate the blog system. There are two collection (articles / comments), schema as follows
// Query for comment
// Params: { offset / limit / sortBy }
exports.getComments = function(req, res) {
  let count;
  let data;
  let { offset, limit, sortBy } = req.query;
  let { aid } = req.params

  // Get Total count
  Comment.estimatedDocumentCount(function(err, num) {
    if (err) {
      errCallback(err, res);
      return
    }
    count = num;
  });
  offset = Number(offset);
  limit = Number(limit);
  console.log("aid", aid);
  Article.findById(aid).
  populate("comments").
  // skip(offset).
  // limit(limit).
  // sort(dueSortby(sortBy)).
  exec((err, comment) => {
    console.log("execed!", comment)
    data = comment;
    getCountCallback(data, count, res);
  });
}

long-winded, I am afraid to lose the details, if there is any solution, please do not hesitate to let me know!

Apr.29,2021
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-1b35473-e4ce.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-1b35473-e4ce.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?