/
distinct_options.go
40 lines (33 loc) · 1.09 KB
/
distinct_options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package mgx
import (
"go.mongodb.org/mongo-driver/mongo/options"
"time"
)
// DistinctOptions is a wrapper around mongo options.
type DistinctOptions struct {
o *options.DistinctOptions
}
// opt returns the underlying mongo option.
func (o *DistinctOptions) opt() *options.DistinctOptions {
return o.o
}
// Collation specifies a collation.
func (o *DistinctOptions) Collation(v *Collation) *DistinctOptions {
o.o.SetCollation(v.Collation)
return o
}
// Comment specifies a string or document that will be included in server logs, profiling logs, and currentOp queries to help trace
// the operation. The default value is nil, which means that no comment will be included in the logs.
func (o *DistinctOptions) Comment(v string) *DistinctOptions {
o.o.SetComment(v)
return o
}
// MaxTime specifies the maximum amount of time to allow the query to run.
func (o *DistinctOptions) MaxTime(v time.Duration) *DistinctOptions {
o.o.SetMaxTime(v)
return o
}
// NewDistinctOptions creates a new DistinctOptions.
func NewDistinctOptions() *DistinctOptions {
return &DistinctOptions{o: options.Distinct()}
}