我想汇总过去一小时内创建的距离字段。
我得到的错误是:"missing type in composite literal"
我的代码:
var lastHour = time.Now()
var hour=lastHour.Hour()-1
pipeline := []bson.M{
{"$match": bson.M{"createdAt":{"$gt":hour} }},
{"$group":
bson.M{"_id": "",
"total distance": bson.M{ "$sum": "$distance" },
"maximum distance": bson.M{ "$max": "$distance" },
"minimum distance": bson.M{ "$min": "$distance" },
},
},