> db.doc.find().pretty();
{
"_id" : ObjectId("55669401a5f628a23fed5adc"),
"cur" : {
"pathname" : "/blog",
"href" : "http://www.example.com/blog/"
},
"visits" : [
{
"url" : "http://www.example.com/blog/",
"gt_ms" : "1110"
}
]
}
{
"_id" : ObjectId("556697eba5f628a23fed5add"),
"cur" : {
"pathname" : "/twcontroller/insights/login.php",
"href" : "http://www.example.com/twcontroller/insights/login.php"
},
"visits" : [
{
"url" : "http://www.example.com/twcontroller/insights/login.php",
"gt_ms" : "990"
}
]
}
{
"_id" : ObjectId("556697eba5f628a23fed5ade"),
"cur" : {
"pathname" : "/",
"href" : "http://www.example.com/"
},
"visits" : [
{
"url" : "http://www.example.com/",
"gt_ms" : "719"
},
{
"url" : "http://www.example.com/",
"gt_ms" : "719"
}
]
}
{
"_id" : ObjectId("556697eba5f628a23fed5adf"),
"cur" : {
"pathname" : "/",
"href" : "http://www.example.com/"
},
"visits" : [
{
"url" : "http://www.example.com/",
"gt_ms" : "62"
},
{
"url" : "http://www.example.com/",
"gt_ms" : "62"
},
{
"url" : "http://www.example.com/",
"gt_ms" : "62"
},
{
"url" : "http://www.example.com/",
"gt_ms" : "62"
},
{
"url" : "http://www.example.com/",
"gt_ms" : "62"
},
{
"url" : "http://www.example.com/",
"gt_ms" : "62"
},
{
"url" : "http://www.example.com/",
"gt_ms" : "62"
}
]
}
I want to match the value of cur.pathname
with the visits[0].url
(i.e., the first item in the array visits) and returns its count. Also want to return the count of visits array which is having only one array element.
How can I do this?