go-bongo / bongo

Go ODM for MongoDB
MIT License
487 stars 40 forks source link

CascadeSave should sync #40

Open wxf4150 opened 5 years ago

wxf4150 commented 5 years ago

this commit fixes #36

wxf4150 commented 5 years ago

DocumentBase fields should omitempty; then the sub struct can used as bongo.Find param.


type User struct {
    bongo.DocumentBase `bson:",inline"`
    UserName     string `example:"wxf"`
    Password string `json:"-" example:"111111"  bson:",omitempty"`
    Phone string ` bson:",omitempty"`
    Email string ` bson:",omitempty"`
}
u:=new(User)
err:=bgoUser.FindOne(bson.M{"username":uname},u)  

err:=bgoUser.FindOne(User{UserName:uname},u)  // if DocumentBase fields  bson omitempty;  then this line will work too.
coveralls commented 5 years ago

Coverage Status

Coverage decreased (-1.02%) to 84.064% when pulling 6721120325b9aef9466d87a751c00d4cdd66f4a2 on wxf4150:master into 761759e31d8fed917377aa7085db01d218ce50d8 on go-bongo:master.

coveralls commented 5 years ago

Coverage Status

Coverage decreased (-1.02%) to 84.064% when pulling 6721120325b9aef9466d87a751c00d4cdd66f4a2 on wxf4150:master into 761759e31d8fed917377aa7085db01d218ce50d8 on go-bongo:master.

coveralls commented 5 years ago

Coverage Status

Coverage decreased (-1.02%) to 84.064% when pulling 6721120325b9aef9466d87a751c00d4cdd66f4a2 on wxf4150:master into 761759e31d8fed917377aa7085db01d218ce50d8 on go-bongo:master.

coveralls commented 5 years ago

Coverage Status

Coverage decreased (-1.02%) to 84.064% when pulling 6721120325b9aef9466d87a751c00d4cdd66f4a2 on wxf4150:master into 761759e31d8fed917377aa7085db01d218ce50d8 on go-bongo:master.