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])
}
My map is like this : m map[string]Language
and Language is :
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?