【发布时间】:2014-07-05 13:17:26
【问题描述】:
这里我有两个文档,我需要查询以获取 title="post one" 和 comments: userid="1" 我只想获取具有上述条件的 cmets。不是所有的 cmets。
` { "_id": ObjectId("53b7f2383ed7755c2400002e"), "title": "帖子一", “作者”:“鲍勃”, “已发布”:ISODate(“2014-07-05T12:40:24.0Z”), "pageViews": NumberInt(5), “cmets”:{ “0”:{ “用户名”:“1”, “文本”:“这很酷” }, “1”:{ “用户名”:“2”, “文本”:“这很糟糕” }, “3”:{ “用户名”:“3”, "text": "这是个坏例子" } “4”:{ “用户名”:“4”, “文本”:“不谢” } “5”:{ “用户名”:“1”, “文本”:“没关系” } “6”:{ “用户名”:“1”, “文本”:“测试” } “7”:{ “用户名”:“1”, "text": "No Its Fine ok not bad" } “8”:{ “用户名”:“1”, "text": "测试 ddd" }
} } `
{
"_id": ObjectId("53b7f2383ed7755c2400002e"),
"title": "Post Two",
"author": "bob",
"posted": ISODate("2014-07-05T12:40:24.0Z"),
"pageViews": NumberInt(5),
"comments": {
"0": {
"userid": "1",
"text": "this is cool"
},
"1": {
"userid": "2",
"text": "this is bad"
},
"3": {
"userid": "3",
"text": "this is badexample"
}
"4": {
"userid": "4",
"text": "No Thanx"
}
}
}
【问题讨论】: