从文档数组中检索零件(Retrieve part from an Array of Document)
我正在使用mongodb和php构建一个项目,所以我的数据库包含以下记录。
{ "_id": { "$id": "515bb7e2a00b2add0b000001" }, "user_id": "user_8888", "events": { "common test I": { "subject": "common 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" } } }所以只使用查询,我如何从记录中检索“常见测试I”事件。 结果应该是:
{ "subject": "common 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" }可能吗?
I am building a project using mongodb and php, so my database contains the following record.
{ "_id": { "$id": "515bb7e2a00b2add0b000001" }, "user_id": "user_8888", "events": { "common test I": { "subject": "common 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" } } }So only using query, how I retrieve "common test I" event from the record. The result should be:
{ "subject": "common 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" }Is it possible?
最满意答案
db.collection.find({},{"events.common test I":1,_id:0})
db.collection.find({},{"events.common test I":1,_id:0})
更多推荐
发布评论