Hi,
I’m not sure if your aggregation pipeline is correct, but you should be able to verify the correctness using the shell and some test data. If the ordering of the pipeline matters, I’d recommend using an ordered type like bson.D. bson.M is a map[string]interface{} and the Go language does not guarantee that maps will have the same order each time they’re iterated.
– Divjot