@@ -14,49 +14,18 @@ import (
14
14
15
15
// AggregateOptions represents arguments that can be used to configure an
16
16
// Aggregate operation.
17
+ //
18
+ // See corresponding setter methods for documentation.
17
19
type 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
29
22
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
60
29
}
61
30
62
31
// AggregateOptionsBuilder contains options to configure aggregate operations.
@@ -76,7 +45,8 @@ func (ao *AggregateOptionsBuilder) List() []func(*AggregateOptions) error {
76
45
return ao .Opts
77
46
}
78
47
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.
80
50
func (ao * AggregateOptionsBuilder ) SetAllowDiskUse (b bool ) * AggregateOptionsBuilder {
81
51
ao .Opts = append (ao .Opts , func (opts * AggregateOptions ) error {
82
52
opts .AllowDiskUse = & b
@@ -87,7 +57,8 @@ func (ao *AggregateOptionsBuilder) SetAllowDiskUse(b bool) *AggregateOptionsBuil
87
57
return ao
88
58
}
89
59
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.
91
62
func (ao * AggregateOptionsBuilder ) SetBatchSize (i int32 ) * AggregateOptionsBuilder {
92
63
ao .Opts = append (ao .Opts , func (opts * AggregateOptions ) error {
93
64
opts .BatchSize = & i
@@ -98,7 +69,11 @@ func (ao *AggregateOptionsBuilder) SetBatchSize(i int32) *AggregateOptionsBuilde
98
69
return ao
99
70
}
100
71
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.
102
77
func (ao * AggregateOptionsBuilder ) SetBypassDocumentValidation (b bool ) * AggregateOptionsBuilder {
103
78
ao .Opts = append (ao .Opts , func (opts * AggregateOptions ) error {
104
79
opts .BypassDocumentValidation = & b
@@ -109,7 +84,10 @@ func (ao *AggregateOptionsBuilder) SetBypassDocumentValidation(b bool) *Aggregat
109
84
return ao
110
85
}
111
86
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.
113
91
func (ao * AggregateOptionsBuilder ) SetCollation (c * Collation ) * AggregateOptionsBuilder {
114
92
ao .Opts = append (ao .Opts , func (opts * AggregateOptions ) error {
115
93
opts .Collation = c
@@ -120,7 +98,9 @@ func (ao *AggregateOptionsBuilder) SetCollation(c *Collation) *AggregateOptionsB
120
98
return ao
121
99
}
122
100
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.
124
104
func (ao * AggregateOptionsBuilder ) SetMaxAwaitTime (d time.Duration ) * AggregateOptionsBuilder {
125
105
ao .Opts = append (ao .Opts , func (opts * AggregateOptions ) error {
126
106
opts .MaxAwaitTime = & d
@@ -131,7 +111,9 @@ func (ao *AggregateOptionsBuilder) SetMaxAwaitTime(d time.Duration) *AggregateOp
131
111
return ao
132
112
}
133
113
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.
135
117
func (ao * AggregateOptionsBuilder ) SetComment (comment interface {}) * AggregateOptionsBuilder {
136
118
ao .Opts = append (ao .Opts , func (opts * AggregateOptions ) error {
137
119
opts .Comment = comment
@@ -142,7 +124,10 @@ func (ao *AggregateOptionsBuilder) SetComment(comment interface{}) *AggregateOpt
142
124
return ao
143
125
}
144
126
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.
146
131
func (ao * AggregateOptionsBuilder ) SetHint (h interface {}) * AggregateOptionsBuilder {
147
132
ao .Opts = append (ao .Opts , func (opts * AggregateOptions ) error {
148
133
opts .Hint = h
@@ -153,7 +138,11 @@ func (ao *AggregateOptionsBuilder) SetHint(h interface{}) *AggregateOptionsBuild
153
138
return ao
154
139
}
155
140
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").
157
146
func (ao * AggregateOptionsBuilder ) SetLet (let interface {}) * AggregateOptionsBuilder {
158
147
ao .Opts = append (ao .Opts , func (opts * AggregateOptions ) error {
159
148
opts .Let = let
0 commit comments