假设我们有以下结构:
type shop struct {
ID primitive.ObjectID `json:"_id,omitempty" bson:"_id,omitempty"`
Brands *brand `json:"brand,omitempty" bson:"brand,omitempty"`
}
type brand struct {
ID primitive.ObjectID `json:"_id,omitempty" bson:"deploymentid,omitempty"`
}
我尝试findOne()
使用 MongoDB 查找一个文档,但即使有结果匹配,我也没有得到任何文档。
filter := bson.M{"brand" : bson.M{"_id" : someValue}}
var shopWithBrand shop
mycollection.findOne(ctx , filter).Decode(&shopWithBrand)
我犯了什么错误?