目前我们正在将 mgo( globalsign )驱动程序迁移到 go mongo-driver
我想要一些替代方法Find.().One()
我尝试了类似下面的方法,但没有帮助
login = model.LoginModel{}
err = mongo.Collection.Find(bson.M{"name": MAXCOUNT}).Decode(&loginCount)
返回我并返回以下错误,
error was: cannot transform type []interface {} to a BSON Document: WriteArray can only write a Array while positioned on a Element or Value but is positioned on a TopLevel
不确定新的 Decode 方法是否允许结构值?
我的结构如下所示
type LoginModel struct {
Username string `json:"username"`
Password string `json:"password"`
}
我也需要有相应的 bson 值吗?
试图在 go-mongo-driver 中运行 Find.().One()
幕布斯6054654
相关分类