如何从嵌套的mongodb文档中获取每个日期的entires计数?

时间:2016-10-02 03:18:16

标签: php mongodb mapreduce aggregation-framework

我是MONGODB的新手。 我需要使用MAPREDUCE函数获取每个DEPLOYED日期的条目数,直到今天。我厌倦了寻找答案但根据我的需要没有匹配。请帮助!

我试过这个但是没有工作。 How to get the count of records on each date in mongodb?

甚至累了许多其他人,但仍然徒劳无功。

我正在尝试为这个编写一个PHP代码,但即使你只是通过mongodb帮助我,我可以做其余的事情。在此先感谢。

P.S。 - 我读到了关于从_id获取约会的事情,我尝试了但仍然徒劳无功。

我的Mongodb结构

{
"_id" : ObjectId("57e90143fe649e701e156e8d"),
"description" : "log_details",
"servicelog" : [
    {
        "_id" : ObjectId("57e901436803fa2125f7b82a"),
        "name" : "Sam",
        "gender" : "Male",
        "telephone" : "1234567543",
        "pincode" : "1234",
        "servicetype" : "ambulance",
        "assigned_vehiclenumber" : "MH12AA0001",
        "Deploy_Timestamp" : {
            "date" : "2016-09-26 16:36:43",
            "timezone_type" : 3,
            "timezone" : "Asia/Calcutta"
        },
        "Release_Timestamp" : {
            "date" : "2016-09-26 16:51:26",
            "timezone_type" : 3,
            "timezone" : "Asia/Calcutta"
        }
    },
    {
        "_id" : ObjectId("57e904cd6803fa2125f7b82b"),
        "name" : "Ram",
        "gender" : "Male",
        "telephone" : "6543134",
        "pincode" : "411011",
        "servicetype" : "ambulance",
        "assigned_vehiclenumber" : "MH12AA0001",
        "Deploy_Timestamp" : {
            "date" : "2016-09-26 16:51:49",
            "timezone_type" : 3,
            "timezone" : "Asia/Calcutta"
        },
        "Release_Timestamp" : {
            "date" : "2016-09-26 17:00:19",
            "timezone_type" : 3,
            "timezone" : "Asia/Calcutta"
        }
    },

    {
        "_id" : ObjectId("57e90e9a6803fa6879f7b82d"),
        "name" : "Atharva",
        "gender" : "Male",
        "telephone" : "12343143",
        "pincode" : "34532",
        "servicetype" : "ambulance",
        "assigned_vehiclenumber" : "MH12AA0001",
        "Deploy_Timestamp" : {
            "date" : "2016-09-26 17:33:38",
            "timezone_type" : 3,
            "timezone" : "Asia/Calcutta"
        },
        "Release_Timestamp" : {
            "date" : "2016-09-26 18:28:39",
            "timezone_type" : 3,
            "timezone" : "Asia/Calcutta"
        }
    },
  .....
}

0 个答案:

没有答案