好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

mongodb sort

往常使用 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   问题   

查看更多关于mongodb sort的详细内容...

  阅读:29次