假设设置如下:
blogposts
{
title:"Example",
slug:"example-post"
tags: ["foo", "bar"]
},
{
title:"Example2",
slug:"example2"
tags: ["foo"]
}
news
{
headline: "Test"
slug: "test-news"
tags: ["bar"]
}
我知道我可以获取所有具有特定标签的博客文章:
$cursor = $blogposts->find(array('tags' => 'bar'));
但是有没有一种方法可以一次查询多个集合以获取具有该标签的所有文档?例如,显示所有带有标签“bar”的内容。