I am new to mongodb-go-driver. But i am stuck.
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])
}
When look at the contents of m[id], it has no content - all nulls.
My map is like this : m map[string]Language
and Language is defined like :
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"`
}
What am I doing wrong?
I am learning using this example : https://github.com/mongodb/mongo-go-driver/blob/master/examples/documentation_examples/examples.go