I have something like...
type Item struct {
Name string `json:"name" bson:"name"`
Config map[string]interface{} `json:"config" bson:"config,inline"`
}
func (repository *ItemRepository) UpdateConfig(id string, config map[string]interface{}) {
change := mgo.Change{
Update: bson.M{"$set": bson.M{
"config": config,
}},
},
}
But I get an error Raw Unmarshal can't deal with struct values. Use a pointer.
. I'm not entirely sure what this means, or what's expected. Is it possible to just store 'loose' data as a sub-document?
I fixed this by using Update
instead of FindId(id).Apply(change, nil)
.