小编Ubu*_*Man的帖子

无法使用 mongo-go-driver 解码驼峰字段

我正在使用这样的结构

type User struct {
    Username  string    `json: "username" bson: "username"`
    FirstName string    `json: "firstName" bson: "firstName"`
    LastName  string    `json: "lastName" bson: "lastName"`
    Email     string    `json: "email" bson: "email"`
    Gender    string    `json: "gender" bson: "gender"`
    Password  string    `json: "password" bson: "password"`
    Enabled   bool      `json: "enabled" bson: "enabled"`
    BirthDate time.Time `json: "birthDate" bson: "birthDate"`
    CreatedAt time.Time `json: "createdAt" bson: "createdAt"`
    UpdatedAt time.Time `json: "updatedAt" bson: "updatedAt"`
    collection *mongo.Collection
}
Run Code Online (Sandbox Code Playgroud)

然后使用查询数据

func (u *User) FindByUsername(userName string) error {
    var ctx, _ = …
Run Code Online (Sandbox Code Playgroud)

go bson mongo-go

-1
推荐指数
1
解决办法
789
查看次数

标签 统计

bson ×1

go ×1

mongo-go ×1