I have read doc of Mongo Stitch, but still failed to query mongodb.
The aim is to statistic daily data input in mongodb for recent 15 days. “$create_time” is the datetime string at insertion (eg. “2019-04-20 15:20:30”). The problem is how to group by date.
Any advice is welcome.
{
"collection": "maoyan",
"aggregate": [
{"$project": {
"create_time":"$create_time",
"ago_15":{
"$dateToString": {
"format": "%Y-%m-%d",
"date": {"$date": "ISODate().getTime() - 1000*3600*24*15)"
}
}
}
},
{
"$match": {
"create_time": {
"$gt": "$ago_15"
}
}
},
{
"$group": {
"_id": {
"$substr": [
"$create_time",
0,
10
]
},
"count":{"$sum":1}
}
}
]
}