> 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 map the value cur.pathnameto visits[0].url(i.e. the first element in an array visit) and return its score. It is also necessary to return an array of count visits, which has only one element of the array.
How can i do this?
source
share