内嵌集合怎么查询
浮世修 2014-06-17 05:24:26 假设有个文章的集合,里面有两文章,结构如下所示,我想查询,标题是“abc”的文章里,一共有几条评论"comment"
如第一篇查出来是2个 第二篇 查出来是1个 如果把.count()改成 .find() 能查到具体内容
用
db.articles.count( {...} )
这里的查询条件应该和find一样用法吧,但是{...} 里面怎么写呢
网上搜了有内嵌文档插查询的,但是内嵌集合查询的没找到
db.articles
{
"title" : "abc",
"content" : "abcdefg",
"comment" : {
{
"id" : "sam",
"content" : "good"
}
{
"id" : "bill",
"content" : "nice"
}
}
}
{
"title" : "bcd",
"content" : "aabbcc",
"comment" : {
{
"id" : "tom",
"content" : "fantastic"
}
}
}
我是个刚入门的菜鸟,望各位指教。