MongoDB - 按值过滤子文档

时间:2014-10-22 03:46:29

标签: mongodb

我有这样的文件:

{
    "_id" : ObjectId("544638f66ffd8c580e000003"),
    "Cars" : {
        "title" : "Xe ô tô",
        "category" : "53f5cce56ffd8cd415000003",
        "show" : "1",
        "action" : {
            "manager" : {
                "title" : "Xe",
                "show" : "1"
            }
        }
    },
    "Hotels" : {
        "title" : "Khách sạn",
        "category" : "53f5c88a6ffd8cd415000002",
        "show" : "1",
        "action" : {
            "manager_index" : {
                "title" : "Xem",
                "show" : "1"
            },
            "manager_setup_room" : {
                "title" : "Cài đặt phòng",
                "show" : "1"
            },
            "manager_rating" : {
                "title" : "Đánh giá",
                "show" : "1"
            },
            "manager_add" : {
                "title" : "Thêm",
                "show" : "1"
            }
        }
    },
    "OrderHotels" : {
        "title" : "",
        "category" : "540927688621afac17000000",
        "show" : "0",
        "action" : {
            "manager" : {
                "title" : "",
                "show" : "0"
            }
        }
    },
    "Roles" : {
        "title" : "",
        "category" : "540927688621afac17000000",
        "show" : "0",
        "action" : {
            "manager_hotel" : {
                "title" : "",
                "show" : "0"
            }
        }
    },
    "Users" : {
        "title" : "",
        "category" : "540927688621afac17000000",
        "show" : "0",
        "action" : {
            "manager_index" : {
                "title" : "",
                "show" : "0"
            },
            "manager_add" : {
                "title" : "",
                "show" : "0"
            },
            "manager_delete" : {
                "title" : "",
                "show" : "0"
            },
            "manager" : {
                "title" : "",
                "show" : "0"
            }
        }
    },
    "modified" : ISODate("2014-10-22T02:40:58.000Z"),
    "created" : ISODate("2014-10-21T10:44:06.000Z"),
}

我想只显示具有相同类别(在其中)的对象,例如:

  • 53f5cce56ffd8cd415000003:汽车,CarType,......
  • 53f5cce56ffd8cd415000004:酒店,房间,......

帮我解决一下!

0 个答案:

没有答案