我是mongodb-go-driver的新手。但是我被困住了。cursor, e := collection.Find(context.Background(), bson.NewDocument(bson.EC.String("name", id)))for cursor.Next(context.Background()) { e := bson.NewDocument() cursor.Decode(e) b, _ := e.MarshalBSON() err := bson.Unmarshal(b, m[id])}當查看m [id]的內容時,它沒有內容-全部為null。我的地圖是這樣的:m map [string] Language語言定義如下:type Language struct { ID string `json:"id" bson:"_id"` // is this wrong? Name string `json:"name" bson:"name"` Vowels []string `json:"vowels" bson:"vowels"` Consonants []string `json:"consonants" bson:"consonants"`}我究竟做錯了什么?我正在使用此示例進行學習:https : //github.com/mongodb/mongo-go-driver/blob/master/examples/documentation_examples/examples.go
- 3 回答
- 0 關注
- 401 瀏覽
添加回答
舉報
0/150
提交
取消