假设有三张表:
User: _id, name. 用户
Article: _id, title, content, userId 文章
Comment: _id, articleId, content, userId 评论
如何查询出某个用户发表的所有文章,返回格式如下:
[
{
_id: '',
title: '',
content: '',
userId: '',
userInfo: {
_id: '',
name: ''
} ,
comments: [{
_id: '',
content: '',
userId: '',
userInfo: {
_id: '',
name: ''
}
},{
...
}]
},
...
]