package
0.0.0-20231208061952-f10d33120ced
Repository: https://github.com/liguoqinjim/go-labs.git
Documentation: pkg.go.dev
# README
增删改查
在mongodb中做一些增删改查的操作。
注意点
ObjectId
我们有的时候想直接用objectId来操作document,这个时候我们就要在映射对象里面加上id字段。如下:
type Game struct {
ID bson.ObjectId `bson:"_id,omitempty"` //_id这样可以收到mongodb的id,omitempty可以在insert时候不插入这个值,而是由mongodb自动生成
Winner string `bson:"winner"`
OfficialGame bool `bson:"official_game"`
Location string `bson:"location"`
StartTime time.Time `bson:"start"`
EndTime time.Time `bson:"end"`
Players []Player `bson:"players"`
}
运行结果
参考资料
# Functions
No description provided by the author