【发布时间】:2019-06-07 17:12:13
【问题描述】:
我有这样的结构:
type Meet struct {
Title string `json:title`
Time time.Time `json:time`
Host string `json:host`
Crowd []string `json:crowd`
Geo Location `json:location`
Invoice []Bill `json:invoice`
}
type User struct {
ID bson.ObjectId `json:"id" bson:"_id,omitempty"`
Name string `json:name`
Phone string `json:phone`
Email string `json:email`
Vc string `json:vc`
Status int8 `json:status`
Avatar string `json:avatar`
FriendList []bson.ObjectId `json:friendlist`
Meetings []Meet `json:meetings`
Requests []Request `json:request`
}
并且想要更新会议发票(例如:User.Meetings[0].Invoice) 我的代码是这样的:
query := bson.M{
"_id": bson.ObjectIdHex(personId),
"Meetings.Title": Title,
"Meetings.Geo": Geo,
}
update := bson.M{
"$set": bson.M{
"Meetings.$.Invoice": updateInvoice,
},
}
updateErr = collection.Update(query, update)
我得到的只是没有找到错误。评论会议。地理没有帮助并导致同样的原因。没有找到。 这是我的查询有问题还是什么?
【问题讨论】: