@@ -14,49 +14,18 @@ import (
1414
1515// AggregateOptions represents arguments that can be used to configure an
1616// Aggregate operation.
17+ //
18+ // See corresponding setter methods for documentation.
1719type AggregateOptions struct {
18- // If true, the operation can write to temporary files in the _tmp subdirectory of the database directory path on
19- // the server. The default value is false.
20- AllowDiskUse * bool
21-
22- // The maximum number of documents to be included in each batch returned by the server.
23- BatchSize * int32
24-
25- // If true, writes executed as part of the operation will opt out of document-level validation on the server. This
26- // option is valid for MongoDB versions >= 3.2 and is ignored for previous server versions. The default value is
27- // false. See https://www.mongodb.com/docs/manual/core/schema-validation/ for more information about document
28- // validation.
20+ AllowDiskUse * bool
21+ BatchSize * int32
2922 BypassDocumentValidation * bool
30-
31- // Specifies a collation to use for string comparisons during the operation. This option is only valid for MongoDB
32- // versions >= 3.4. For previous server versions, the driver will return an error if this option is used. The
33- // default value is nil, which means the default collation of the collection will be used.
34- Collation * Collation
35-
36- // The maximum amount of time that the server should wait for new documents to satisfy a tailable cursor query.
37- // This option is only valid for MongoDB versions >= 3.2 and is ignored for previous server versions.
38- MaxAwaitTime * time.Duration
39-
40- // A string or document that will be included in server logs, profiling logs,
41- // and currentOp queries to help trace the operation. The default is nil,
42- // which means that no comment will be included in the logs.
43- Comment interface {}
44-
45- // The index to use for the aggregation. This should either be the index name as a string or the index specification
46- // as a document. The hint does not apply to $lookup and $graphLookup aggregation stages. The driver will return an
47- // error if the hint parameter is a multi-key map. The default value is nil, which means that no hint will be sent.
48- Hint interface {}
49-
50- // Specifies parameters for the aggregate expression. This option is only valid for MongoDB versions >= 5.0. Older
51- // servers will report an error for using this option. This must be a document mapping parameter names to values.
52- // Values must be constant or closed expressions that do not reference document fields. Parameters can then be
53- // accessed as variables in an aggregate expression context (e.g. "$$var").
54- Let interface {}
55-
56- // Custom options to be added to aggregate expression. Key-value pairs of the BSON map should correlate with desired
57- // option names and values. Values must be Marshalable. Custom options may conflict with non-custom options, and custom
58- // options bypass client-side validation. Prefer using non-custom options where possible.
59- Custom bson.M
23+ Collation * Collation
24+ MaxAwaitTime * time.Duration
25+ Comment interface {}
26+ Hint interface {}
27+ Let interface {}
28+ Custom bson.M
6029}
6130
6231// AggregateOptionsBuilder contains options to configure aggregate operations.
@@ -76,7 +45,8 @@ func (ao *AggregateOptionsBuilder) List() []func(*AggregateOptions) error {
7645 return ao .Opts
7746}
7847
79- // SetAllowDiskUse sets the value for the AllowDiskUse field.
48+ // SetAllowDiskUse sets the value for the AllowDiskUse field. If true, the operation can write to temporary
49+ // files in the _tmp subdirectory of the database directory path on the server. The default value is false.
8050func (ao * AggregateOptionsBuilder ) SetAllowDiskUse (b bool ) * AggregateOptionsBuilder {
8151 ao .Opts = append (ao .Opts , func (opts * AggregateOptions ) error {
8252 opts .AllowDiskUse = & b
@@ -87,7 +57,8 @@ func (ao *AggregateOptionsBuilder) SetAllowDiskUse(b bool) *AggregateOptionsBuil
8757 return ao
8858}
8959
90- // SetBatchSize sets the value for the BatchSize field.
60+ // SetBatchSize sets the value for the BatchSize field. Specifies the maximum number of documents
61+ // to be included in each batch returned by the server.
9162func (ao * AggregateOptionsBuilder ) SetBatchSize (i int32 ) * AggregateOptionsBuilder {
9263 ao .Opts = append (ao .Opts , func (opts * AggregateOptions ) error {
9364 opts .BatchSize = & i
@@ -98,7 +69,11 @@ func (ao *AggregateOptionsBuilder) SetBatchSize(i int32) *AggregateOptionsBuilde
9869 return ao
9970}
10071
101- // SetBypassDocumentValidation sets the value for the BypassDocumentValidation field.
72+ // SetBypassDocumentValidation sets the value for the BypassDocumentValidation field. If true, writes
73+ // executed as part of the operation will opt out of document-level validation on the server. This
74+ // option is valid for MongoDB versions >= 3.2 and is ignored for previous server versions. The default value
75+ // is false. See https://www.mongodb.com/docs/manual/core/schema-validation/ for more information about
76+ // document validation.
10277func (ao * AggregateOptionsBuilder ) SetBypassDocumentValidation (b bool ) * AggregateOptionsBuilder {
10378 ao .Opts = append (ao .Opts , func (opts * AggregateOptions ) error {
10479 opts .BypassDocumentValidation = & b
@@ -109,7 +84,10 @@ func (ao *AggregateOptionsBuilder) SetBypassDocumentValidation(b bool) *Aggregat
10984 return ao
11085}
11186
112- // SetCollation sets the value for the Collation field.
87+ // SetCollation sets the value for the Collation field. Specifies a collation to use for string
88+ // comparisons during the operation. This option is only valid for MongoDB versions >= 3.4. For previous
89+ // server versions, the driver will return an error if this option is used. The default value is nil,
90+ // which means the default collation of the collection will be used.
11391func (ao * AggregateOptionsBuilder ) SetCollation (c * Collation ) * AggregateOptionsBuilder {
11492 ao .Opts = append (ao .Opts , func (opts * AggregateOptions ) error {
11593 opts .Collation = c
@@ -120,7 +98,9 @@ func (ao *AggregateOptionsBuilder) SetCollation(c *Collation) *AggregateOptionsB
12098 return ao
12199}
122100
123- // SetMaxAwaitTime sets the value for the MaxAwaitTime field.
101+ // SetMaxAwaitTime sets the value for the MaxAwaitTime field. Specifies maximum amount of time
102+ // that the server should wait for new documents to satisfy a tailable cursor query. This option is
103+ // only valid for MongoDB versions >= 3.2 and is ignored for previous server versions.
124104func (ao * AggregateOptionsBuilder ) SetMaxAwaitTime (d time.Duration ) * AggregateOptionsBuilder {
125105 ao .Opts = append (ao .Opts , func (opts * AggregateOptions ) error {
126106 opts .MaxAwaitTime = & d
@@ -131,7 +111,9 @@ func (ao *AggregateOptionsBuilder) SetMaxAwaitTime(d time.Duration) *AggregateOp
131111 return ao
132112}
133113
134- // SetComment sets the value for the Comment field.
114+ // SetComment sets the value for the Comment field. Specifies a string or document that will be included in
115+ // server logs, profiling logs, and currentOp queries to help trace the operation. The default is nil,
116+ // which means that no comment will be included in the logs.
135117func (ao * AggregateOptionsBuilder ) SetComment (comment interface {}) * AggregateOptionsBuilder {
136118 ao .Opts = append (ao .Opts , func (opts * AggregateOptions ) error {
137119 opts .Comment = comment
@@ -142,7 +124,10 @@ func (ao *AggregateOptionsBuilder) SetComment(comment interface{}) *AggregateOpt
142124 return ao
143125}
144126
145- // SetHint sets the value for the Hint field.
127+ // SetHint sets the value for the Hint field. Specifies the index to use for the aggregation. This should
128+ // either be the index name as a string or the index specification as a document. The hint does not apply to
129+ // $lookup and $graphLookup aggregation stages. The driver will return an error if the hint parameter
130+ // is a multi-key map. The default value is nil, which means that no hint will be sent.
146131func (ao * AggregateOptionsBuilder ) SetHint (h interface {}) * AggregateOptionsBuilder {
147132 ao .Opts = append (ao .Opts , func (opts * AggregateOptions ) error {
148133 opts .Hint = h
@@ -153,7 +138,11 @@ func (ao *AggregateOptionsBuilder) SetHint(h interface{}) *AggregateOptionsBuild
153138 return ao
154139}
155140
156- // SetLet sets the value for the Let field.
141+ // SetLet sets the value for the Let field. Specifies parameters for the aggregate expression. This
142+ // option is only valid for MongoDB versions >= 5.0. Older servers will report an error for using this
143+ // option. This must be a document mapping parameter names to values. Values must be constant or closed
144+ // expressions that do not reference document fields. Parameters can then be accessed as variables in
145+ // an aggregate expression context (e.g. "$$var").
157146func (ao * AggregateOptionsBuilder ) SetLet (let interface {}) * AggregateOptionsBuilder {
158147 ao .Opts = append (ao .Opts , func (opts * AggregateOptions ) error {
159148 opts .Let = let
0 commit comments