I'm trying to retrieve random records from my mongodb
collection.
I'm using golang
with mongo-go-driver
pipeline := []bson.E{bson.E{"$sample", bson.E{"size", 10}}}
collection.Aggregate(context.TODO(), pipeline)
The aggregate is returning me this error:
A pipeline stage specification object must contain exactly one field.
I've tried with $size
and size
Is it possible that mongo-go-driver
doesn't support $sample?