0
- 數據庫MongoDB的
- 程序語言Golang
- 數據驅動的MgO
type Organizations struct {
Id bson.ObjectId `json:"_id"`
Name string `json:"name"`
Area string `json:"area"`
Type string `json:"type"`
CustomerType string `json:"customertype"`
State string `json:"state"`
LastUpdated string `json:"lastupdated"`
Assigned string `json:"assigned"`
Address `json:"address"`
}
陣列結構,其屬於組織
type Sections struct {
Name string `json:"name" bson:"name"`
Upper string `json:"upper" bson:"upper"`
Master string `json:"master" bson:"master"`
Uppermaster string `json:"uppermaster" bson:"uppermaster"`
OrgID bson.ObjectId `json:"orgid"`
}
我的查詢命令
result := []Sections{}
collection.Find(bson.M{"_id": bson.ObjectIdHex(orgid),
"sections": bson.M{"$exists": true}}).All(&result)
最後,我得到陣列的文件。
但是,我只想得到文件中「Sections」數組的數據。
我該怎麼辦?
謝謝!
非常感謝您! – Aaron