I have the following mongo data which looks like this
{
eventType : "mousedown",
eventArgs : {
type : "touchstart",
elementId : "id1"
},
creationDateTime : ISODate("2017-02-24T07:05:49.986Z")
}
I wrote the following query to perform group count.
db.analytics.aggregate
(
{
$match :
{
$and :
[
{"eventArgs.type" : 'touchstart'},
{eventType : 'mousedown'},
{creationDateTime : {$gte : ISODate("2017-02-24T000:00:00.000Z")}}
]
}
},
{
$group :
{
_id :
{
"eventsArgs.elementId" : "$elementId"
},
count :
{
$sum : 1
}
}
}
);
I'm getting error for $group
, which states that
FieldPath field names may not contain '.'
If I were not able to specific '.' in
$group :
{
_id :
{
"eventsArgs.elementId" : "$elementId"
},
What is the correct way to do so?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…