struct and method:
type Group struct {
Id int64 `bson:"_id,omitempty"`
MediaFilterExceptionUserIds []int `bson:"media_filter_exception_user_ids,omitempty"`
}
func (g *Group) Save() error {
return DB.C("groups").UpdateId(g.Id, bson.M{"$set": &g})
}
func (g *Group) FindById() error {
return DB.C("groups").FindId(g.Id).One(&g)
}
trying to set media_filter_exception_user_ids to an empty []int{} and it doesn't work:
group := Group{}
group.FindById(123)
group.MediaFilterExceptionUserIds = []int{}
group.Save()
It works when there's an item inside the slice, but empty slice is not set.