dsghpgmay31938863 2013-04-03 12:01
浏览 46
已采纳

从文档数组中检索零件

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?

  • 写回答

2条回答 默认 最新

  • douxiongye5779 2013-04-03 12:08
    关注

    db.collection.find({},{"events.common test I":1,_id:0})

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记