I have a document with id, timestamp and a value field. How can I use aggregate function to get avg, min and max grouped by id and everyday? Here’s the snippet I am using. The snippet has a flaw that it use timestamp and not the date part from the timestamp. Any help would be appcreciated much.
document = db_collection.aggregate(
{
"$group": {"_id": {"$device_id"},
"timestamp": {"$timestamp"},
"average": {"$avg": "$value"},
"minimum": {"$min": "$value"},
"maximum": {"$max": "$value"}
}
}
)