我正在使用 mongodb 做项目。所以在这里我只需要检索在文档元素数组上搜索的文档的选定字段。这是我的例子。
{
"_id": {
"$id": "515ce66ca00b2aa30a000000"
},
"user_id": "user_1111",
"events": [
{
"subject": "it test I",
"start_date": "04/14/2013",
"start_time": "8.00 AM",
"end_date": "04/14/2013",
"end_time": "10.30 AM",
"all_day_event": "false",
"discription": "no discription",
"location": "STC",
"private": "false",
"time_zone": "IST",
"alarm": "true",
"alarm_threshold": "5",
"status": "true"
}
]
}
所以在这里我需要检索以下结果。
{
"subject": "it test I",
"start_date": "04/14/2013",
"start_time": "8.00 AM",
"end_date": "04/14/2013",
"end_time": "10.30 AM",
"all_day_event": "false",
"discription": "no discription",
"location": "STC",
"private": "false",
"time_zone": "IST",
"alarm": "true",
"alarm_threshold": "5",
"status": "true"
}
搜索
{"events.subject":"it test I"} 我是怎么做的。请帮我。