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.Nex
Update: New changes were made recently, now have to change to:
import "github.com/mongodb/mongo-go-driver/bson/primitive"
type Language struct {
ID primitive.ObjectID `bson:"_id,omitempty"` // omitempty to protect against zeroed _id insertion
Name string `json:"name" bson:"name"`
Vowels []string `json:"vowels" bson:"vowels"`
Consonants []string `json:"consonants" bson:"consonants"`
}
And take the ID value:
log.Println("lang id:", objLang.ID)
...