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.
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?
我通过使用Update
而不是FindId(id).Apply(change, nil)
来修复此问题FindId(id).Apply(change, nil)
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.