顯示「發佈 - 複合集」的孩子考慮在https://github.com/englue/meteor-publish-composite如何在模板視圖
如何顯示在模板視圖嵌套的孩子給出的例子。我的意思是,顯示關於帖子前2條評論關於查看。
我在互聯網上搜索了很多這個模板視圖上的這個兒童樹顯示,沒有找到任何。
代碼
publishComposite('topTenPosts', {
find() {
// Find top ten highest scoring posts
return Posts.find({}, { sort: { score: -1 }, limit: 10 });
},
children: [
{
find(post) {
// Find post author. Even though we only want to return
// one record here, we use "find" instead of "findOne"
// since this function should return a cursor.
return Meteor.users.find(
{ _id: post.authorId },
{ fields: { profile: 1 } });
}
},
{
find(post) {
// Find top two comments on post
return Comments.find(
{ postId: post._id },
{ sort: { score: -1 }, limit: 2 });
},
children: [
{
find(comment, post) {
// Find user that authored comment.
return Meteor.users.find(
{ _id: comment.authorId },
{ fields: { profile: 1 } });
}
}
]
}
]
});
客戶端數據庫中沒有實際的樹。每個文檔都轉到相應的集合。到目前爲止你嘗試了什麼,你卡在哪裏? – MasterAM