【发布时间】:2015-07-24 18:33:51
【问题描述】:
我有一个类似于以下示例的 Mongo 集合,我正在使用流星发布复合,https://atmospherejs.com/reywood/publish-composite 将文档发布到客户端。我知道使用 Mongo 我可以执行以下操作来返回作者数组中的特定项目。
db.books.find({"authors.authorSlug": "author-1}, {authors: {$elemMatch: { authorSlug: "author-1"}});
当我尝试使用meteor-publish-composite 实现相同的目标时,这似乎不起作用,因为它返回整个作者的数组,我的代码如下。
Books.find({"authors.authorSlug": slug}, {authors: {$elemMatch:{authorSlug: slug}}});
这甚至可以通过发布复合来实现吗?
{
"title" : "Book1",
"authors" : [
{
"name" : "Author 1",
"authorSlug": "author-1"
},
{
"name" : "Author 2",
"slug" : "author-2"
},
],
"slug" : "book1"
}
【问题讨论】:
标签: meteor mongodb-query meteorite