article.js 393 B

12345678910111213
  1. const {Article} = require('../../model/article');
  2. const {Comment} = require('../../model/comment');
  3. module.exports = async (req, res) => {
  4. const id = req.query.id;
  5. const article = await Article.findOne({_id: id}).populate('author');
  6. const comments = await Comment.find({aid: id}).populate('uid');
  7. console.log(article);
  8. res.render('home/article', {
  9. article,
  10. comments
  11. });
  12. };