I have my documents in this format:
{
"_id": 1517209200000,
"timestamp": 1517209200000,
"current": 236078,
}
Timestamp is an epoch representation of a date, with about 100 documents inserted per day. It's stored as a number.
I'm trying to figure out how to print last 30 days with average $current
as well as min and max for each day.
I found the $dayOfYear aggregation however I am not sure how to apply it to my epoch timestamps. (https://docs.mongodb.com/manual/reference/operator/aggregation/dayOfYear/)
Could anyone share their knowledge if they know the answer?
Thank you
EDIT: my first attempt that returns an error: "errmsg" : "can't convert from BSON type double to Date",
db.cable23.aggregate([ { $match: {'direction': 0} },{$group : {'_id': {'$year': "$timestamp"}}}])