Hi,
Is it possible to control the sort order and limit when usung the go driver’s collection.Distinct method ?
Looking at DistinctOptions, and following the links to the implementation, i can’t see how to do this.
Thanks,
Robin
Hi,
Is it possible to control the sort order and limit when usung the go driver’s collection.Distinct method ?
Looking at DistinctOptions, and following the links to the implementation, i can’t see how to do this.
Thanks,
Robin
Hi @Robin_Bryce, and welcome to the forum
The distinct
method here is referring to the MongoDB’s distinct command. Unfortunately the original command does not have options to sort/limit as well.
An alternative to this is to utilise aggregation pipeline $group stage, and combined with $sort and $limit. See also Retrieve Distinct Values for more information.
Regards,
Wan.
This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.