关于 golang mongo model 的映射问题
資深大佬 : chenqh 3
使用的库是 https://github.com/mongodb/mongo-go-driver
model 定义
type MUser struct { Id bson.ObjectId `bson:"_id,omitempty"` CreateAt int64 `bson: "createtime"` IsRemoved int `bson: "hasremoved"` // 登录名 Name string `bson: "name"` // 昵称 Nick string `bson: "nick"` // 密码 PassWord string `bson: "password"` Role string `bson: "role"` Status int `bson: "status"` }
为什么插入的数据是这个样子的?
{ "_id" : ObjectId("5f747b15dedcfdbb4c4ab599"), "createat" : NumberLong(1601469205), "isremoved" : 0, "name" : "sample1", "nick" : "nick", "password" : "5f4dcc3b5aa765d61d8327deb882cf99", "role" : "dev", "status" : 0 }
请大家指点一下?
大佬有話說 (7)