【发布时间】:2021-02-19 06:50:33
【问题描述】:
我正在使用 Mongodb go 驱动程序,但仍在研究如何聚合。 我的问题是,如果我使用 []bson.M 作为管道,如下面的代码所示:
collection.Aggregate(
ctx,
[]bson.M{
bson.M{
"$match": filter,
},
bson.M{
"$sort": sort,
},
},
)
是否确定匹配总是在排序之前?我应该切换到 mongo.Pipeline ([]bson.D) 来 100% 维护订单吗?谢谢
【问题讨论】: