I would like to join two Arrays from one collection based on the array index, not a (primary) key.
The Data looks like this:
{"_id" : ObjectId("1"),
"clicks" : {
"cumulative" : {
"data" : [
3,
7,
8
]
},
"daily" : {
"data" : [
3,
4,
1
]
}
},
"websiteId" : "abcdef"
"day" : {
"isoDate" : [
ISODate("2016-07-07T02:00:00.000+02:00"),
ISODate("2016-07-08T02:00:00.000+02:00"),
ISODate("2016-07-09T02:00:00.000+02:00")
]}
},
....
I would like to join day.isoDate with clicks.cumulative.data based on the index of each array. The table then should look like this:
ObjectID Date Clicks
1 2016-07-07 3
1 2016-07-08 7
1 2016-07-09 8
What I tried so far:
db.collection1.aggregate([
{$unwind: "$day.isoDate"},
{$match: {"websiteId": "abcdef"} },
{$group: {_id: "$day.isoDate.Value"}}
])
Does anybody have a suggestion?