Hi everyone, I new here so I’m not sure this is the right place to ask this question, so here goes.
I am trying to update a project I have from mgo to mongodb go driver.
I am currently getting this error
multiple-value collection.Distinct() in single-value context
from this code:
func GetDistAlbumMeta1() []string{
filter := bson.D{{}}
opts := options.Distinct().SetMaxTime(2 * time.Second)
client, ctx, cancel, err := Connect("mongodb://db:27017/ampgo")
CheckError(err, "MongoDB connection has failed")
collection := client.Database("tempdb1").Collection("meta1")
DAlbum := []string
cur, err := collection.Distinct(context.Background(), "album", filter, opts).Decode(&DAlbum)
CheckError(err, "MongoDB distinct album has failed")
for i, f := range cur {
fmt.Println(f)
}
return DAlbum
}
I have search google for answers, but this one has me perplexed.
Thank in advance for any assistance.
Charlie