往常使用 options.Find().SetSort(bson.D{{"a", -1},{"b", -1}} )结果报错,感觉使用方法没问题,排查之后发现是import的包错了导致。
cannot transform type bson.D to a BSON Document: WriteArray can only write a Array while positioned on a Element or Value but is positioned on a TopLevel
"gopkg.in/mgo.v2/bson" 换成 "go.mongodb.org/mongo-driver/bson" 就没问题了。
mongodb sort
标签:tran not 导致 排查 val top mon find 问题
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did117156