Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
3180407
aggregateoptions
joyjwang Oct 7, 2024
34df9cb
edit
joyjwang Oct 7, 2024
f4a92b8
autoencryptionoptions
joyjwang Oct 7, 2024
f9c5b8f
bulkwriteoptions
joyjwang Oct 7, 2024
2192617
changestreamoptions
joyjwang Oct 7, 2024
29508a4
clientencryptionoptions
joyjwang Oct 7, 2024
5e27d30
collectionoptions
joyjwang Oct 7, 2024
84bd00b
countoptions
joyjwang Oct 7, 2024
759c1c8
createcollectionoptions, defaultindexoptions, timeseriesoptions, crea…
joyjwang Oct 7, 2024
784be7d
datakeyoptions
joyjwang Oct 7, 2024
541b18c
dboptions
joyjwang Oct 7, 2024
4109cb4
deleteoneoptions and deletemanyoptions
joyjwang Oct 7, 2024
8f1197c
distinctoptions
joyjwang Oct 7, 2024
30bbd55
dropcollectionoptions
joyjwang Oct 7, 2024
4c43906
encryptoptions
joyjwang Oct 7, 2024
a922713
estimateddocumentcountoptions
joyjwang Oct 7, 2024
afcbddc
findoptions, findoneoptions, findoneanddeleteoptions, findoneandrepla…
joyjwang Oct 8, 2024
793dba3
bucketoptions, gridfsuploadoptions, gridfsnameoptions, gridfsfindoptions
joyjwang Oct 8, 2024
b26f29e
createindexesoptions, listindexesoptions, indexoptions
joyjwang Oct 8, 2024
c75ca46
insertoneoptions, insertmanyoptions
joyjwang Oct 8, 2024
2955642
listcollectionoptions, listdatabasesoptions
joyjwang Oct 8, 2024
7194b1e
loggeroptions
joyjwang Oct 9, 2024
b38f813
rangeoptions
joyjwang Oct 9, 2024
962f8c6
replaceoptions
joyjwang Oct 9, 2024
f98903b
rewrapmanydatakeyoptions
joyjwang Oct 9, 2024
c1a665c
runcmdoptions
joyjwang Oct 9, 2024
b9eaf31
serverapioptions
joyjwang Oct 9, 2024
16adabe
sessionoptions
joyjwang Oct 9, 2024
92622de
transactionoptions
joyjwang Oct 9, 2024
55df6e9
updateoneoptions, updatemanyoptions
joyjwang Oct 9, 2024
6a86b6f
reformat createindexesoptions
joyjwang Oct 9, 2024
34bbd6a
Merge branch 'master' into GODRIVER-3327
joyjwang Oct 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 38 additions & 49 deletions mongo/options/aggregateoptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,49 +14,18 @@ import (

// AggregateOptions represents arguments that can be used to configure an
// Aggregate operation.
//
// See corresponding setter methods for documentation.
type AggregateOptions struct {
// If true, the operation can write to temporary files in the _tmp subdirectory of the database directory path on
// the server. The default value is false.
AllowDiskUse *bool

// The maximum number of documents to be included in each batch returned by the server.
BatchSize *int32

// If true, writes executed as part of the operation will opt out of document-level validation on the server. This
// option is valid for MongoDB versions >= 3.2 and is ignored for previous server versions. The default value is
// false. See https://www.mongodb.com/docs/manual/core/schema-validation/ for more information about document
// validation.
AllowDiskUse *bool
BatchSize *int32
BypassDocumentValidation *bool

// Specifies a collation to use for string comparisons during the operation. This option is only valid for MongoDB
// versions >= 3.4. For previous server versions, the driver will return an error if this option is used. The
// default value is nil, which means the default collation of the collection will be used.
Collation *Collation

// The maximum amount of time that the server should wait for new documents to satisfy a tailable cursor query.
// This option is only valid for MongoDB versions >= 3.2 and is ignored for previous server versions.
MaxAwaitTime *time.Duration

// A string or document that will be included in server logs, profiling logs,
// and currentOp queries to help trace the operation. The default is nil,
// which means that no comment will be included in the logs.
Comment interface{}

// The index to use for the aggregation. This should either be the index name as a string or the index specification
// as a document. The hint does not apply to $lookup and $graphLookup aggregation stages. The driver will return an
// error if the hint parameter is a multi-key map. The default value is nil, which means that no hint will be sent.
Hint interface{}

// Specifies parameters for the aggregate expression. This option is only valid for MongoDB versions >= 5.0. Older
// servers will report an error for using this option. This must be a document mapping parameter names to values.
// Values must be constant or closed expressions that do not reference document fields. Parameters can then be
// accessed as variables in an aggregate expression context (e.g. "$$var").
Let interface{}

// Custom options to be added to aggregate expression. Key-value pairs of the BSON map should correlate with desired
// option names and values. Values must be Marshalable. Custom options may conflict with non-custom options, and custom
// options bypass client-side validation. Prefer using non-custom options where possible.
Custom bson.M
Collation *Collation
MaxAwaitTime *time.Duration
Comment interface{}
Hint interface{}
Let interface{}
Custom bson.M
}

// AggregateOptionsBuilder contains options to configure aggregate operations.
Expand All @@ -76,7 +45,8 @@ func (ao *AggregateOptionsBuilder) List() []func(*AggregateOptions) error {
return ao.Opts
}

// SetAllowDiskUse sets the value for the AllowDiskUse field.
// SetAllowDiskUse sets the value for the AllowDiskUse field. If true, the operation can write to temporary
// files in the _tmp subdirectory of the database directory path on the server. The default value is false.
func (ao *AggregateOptionsBuilder) SetAllowDiskUse(b bool) *AggregateOptionsBuilder {
ao.Opts = append(ao.Opts, func(opts *AggregateOptions) error {
opts.AllowDiskUse = &b
Expand All @@ -87,7 +57,8 @@ func (ao *AggregateOptionsBuilder) SetAllowDiskUse(b bool) *AggregateOptionsBuil
return ao
}

// SetBatchSize sets the value for the BatchSize field.
// SetBatchSize sets the value for the BatchSize field. Specifies the maximum number of documents
// to be included in each batch returned by the server.
func (ao *AggregateOptionsBuilder) SetBatchSize(i int32) *AggregateOptionsBuilder {
ao.Opts = append(ao.Opts, func(opts *AggregateOptions) error {
opts.BatchSize = &i
Expand All @@ -98,7 +69,11 @@ func (ao *AggregateOptionsBuilder) SetBatchSize(i int32) *AggregateOptionsBuilde
return ao
}

// SetBypassDocumentValidation sets the value for the BypassDocumentValidation field.
// SetBypassDocumentValidation sets the value for the BypassDocumentValidation field. If true, writes
// executed as part of the operation will opt out of document-level validation on the server. This
// option is valid for MongoDB versions >= 3.2 and is ignored for previous server versions. The default value
// is false. See https://www.mongodb.com/docs/manual/core/schema-validation/ for more information about
// document validation.
func (ao *AggregateOptionsBuilder) SetBypassDocumentValidation(b bool) *AggregateOptionsBuilder {
ao.Opts = append(ao.Opts, func(opts *AggregateOptions) error {
opts.BypassDocumentValidation = &b
Expand All @@ -109,7 +84,10 @@ func (ao *AggregateOptionsBuilder) SetBypassDocumentValidation(b bool) *Aggregat
return ao
}

// SetCollation sets the value for the Collation field.
// SetCollation sets the value for the Collation field. Specifies a collation to use for string
// comparisons during the operation. This option is only valid for MongoDB versions >= 3.4. For previous
// server versions, the driver will return an error if this option is used. The default value is nil,
// which means the default collation of the collection will be used.
func (ao *AggregateOptionsBuilder) SetCollation(c *Collation) *AggregateOptionsBuilder {
ao.Opts = append(ao.Opts, func(opts *AggregateOptions) error {
opts.Collation = c
Expand All @@ -120,7 +98,9 @@ func (ao *AggregateOptionsBuilder) SetCollation(c *Collation) *AggregateOptionsB
return ao
}

// SetMaxAwaitTime sets the value for the MaxAwaitTime field.
// SetMaxAwaitTime sets the value for the MaxAwaitTime field. Specifies maximum amount of time
// that the server should wait for new documents to satisfy a tailable cursor query. This option is
// only valid for MongoDB versions >= 3.2 and is ignored for previous server versions.
func (ao *AggregateOptionsBuilder) SetMaxAwaitTime(d time.Duration) *AggregateOptionsBuilder {
ao.Opts = append(ao.Opts, func(opts *AggregateOptions) error {
opts.MaxAwaitTime = &d
Expand All @@ -131,7 +111,9 @@ func (ao *AggregateOptionsBuilder) SetMaxAwaitTime(d time.Duration) *AggregateOp
return ao
}

// SetComment sets the value for the Comment field.
// SetComment sets the value for the Comment field. Specifies a string or document that will be included in
// server logs, profiling logs, and currentOp queries to help trace the operation. The default is nil,
// which means that no comment will be included in the logs.
func (ao *AggregateOptionsBuilder) SetComment(comment interface{}) *AggregateOptionsBuilder {
ao.Opts = append(ao.Opts, func(opts *AggregateOptions) error {
opts.Comment = comment
Expand All @@ -142,7 +124,10 @@ func (ao *AggregateOptionsBuilder) SetComment(comment interface{}) *AggregateOpt
return ao
}

// SetHint sets the value for the Hint field.
// SetHint sets the value for the Hint field. Specifies the index to use for the aggregation. This should
// either be the index name as a string or the index specification as a document. The hint does not apply to
// $lookup and $graphLookup aggregation stages. The driver will return an error if the hint parameter
// is a multi-key map. The default value is nil, which means that no hint will be sent.
func (ao *AggregateOptionsBuilder) SetHint(h interface{}) *AggregateOptionsBuilder {
ao.Opts = append(ao.Opts, func(opts *AggregateOptions) error {
opts.Hint = h
Expand All @@ -153,7 +138,11 @@ func (ao *AggregateOptionsBuilder) SetHint(h interface{}) *AggregateOptionsBuild
return ao
}

// SetLet sets the value for the Let field.
// SetLet sets the value for the Let field. Specifies parameters for the aggregate expression. This
// option is only valid for MongoDB versions >= 5.0. Older servers will report an error for using this
// option. This must be a document mapping parameter names to values. Values must be constant or closed
// expressions that do not reference document fields. Parameters can then be accessed as variables in
// an aggregate expression context (e.g. "$$var").
func (ao *AggregateOptionsBuilder) SetLet(let interface{}) *AggregateOptionsBuilder {
ao.Opts = append(ao.Opts, func(opts *AggregateOptions) error {
opts.Let = let
Expand Down
2 changes: 2 additions & 0 deletions mongo/options/autoencryptionoptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import (
//
// Enabling In-Use Encryption reduces the maximum document and message size (using a maxBsonObjectSize of 2MiB and
// maxMessageSizeBytes of 6MB) and may have a negative performance impact.
//
// See corresponding setter methods for documentation.
type AutoEncryptionOptions struct {
KeyVaultClientOptions Lister[ClientOptions]
KeyVaultNamespace string
Expand Down
35 changes: 15 additions & 20 deletions mongo/options/bulkwriteoptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,13 @@ var DefaultOrdered = true

// BulkWriteOptions represents arguments that can be used to configure a
// BulkWrite operation.
//
// See corresponding setter methods for documentation.
type BulkWriteOptions struct {
// If true, writes executed as part of the operation will opt out of document-level validation on the server. This
// option is valid for MongoDB versions >= 3.2 and is ignored for previous server versions. The default value is
// false. See https://www.mongodb.com/docs/manual/core/schema-validation/ for more information about document
// validation.
BypassDocumentValidation *bool

// 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.
Comment interface{}

// If true, no writes will be executed after one fails. The default value is true.
Ordered *bool

// Specifies parameters for all update and delete commands in the BulkWrite. This option is only valid for MongoDB
// versions >= 5.0. Older servers will report an error for using this option. This must be a document mapping
// parameter names to values. Values must be constant or closed expressions that do not reference document fields.
// Parameters can then be accessed as variables in an aggregate expression context (e.g. "$$var").
Let interface{}
Comment interface{}
Ordered *bool
Let interface{}
}

// BulkWriteOptionsBuilder contains options to configure bulk write operations.
Expand All @@ -52,7 +40,9 @@ func (b *BulkWriteOptionsBuilder) List() []func(*BulkWriteOptions) error {
return b.Opts
}

// SetComment sets the value for the Comment field.
// SetComment sets the value for the Comment field. Specifies a string or document that will be included in
// server logs, profiling logs, and currentOp queries to help tracethe operation. The default value is nil,
// which means that no comment will be included in the logs.
func (b *BulkWriteOptionsBuilder) SetComment(comment interface{}) *BulkWriteOptionsBuilder {
b.Opts = append(b.Opts, func(opts *BulkWriteOptions) error {
opts.Comment = comment
Expand All @@ -63,7 +53,8 @@ func (b *BulkWriteOptionsBuilder) SetComment(comment interface{}) *BulkWriteOpti
return b
}

// SetOrdered sets the value for the Ordered field.
// SetOrdered sets the value for the Ordered field. If true, no writes will be executed after one fails.
// The default value is true.
func (b *BulkWriteOptionsBuilder) SetOrdered(ordered bool) *BulkWriteOptionsBuilder {
b.Opts = append(b.Opts, func(opts *BulkWriteOptions) error {
opts.Ordered = &ordered
Expand All @@ -74,7 +65,11 @@ func (b *BulkWriteOptionsBuilder) SetOrdered(ordered bool) *BulkWriteOptionsBuil
return b
}

// SetBypassDocumentValidation sets the value for the BypassDocumentValidation field.
// SetBypassDocumentValidation sets the value for the BypassDocumentValidation field. If true, writes
// executed as part of the operation will opt out of document-level validation on the server. This option
// is valid for MongoDB versions >= 3.2 and is ignored for previous server versions. The default value is
// false. See https://www.mongodb.com/docs/manual/core/schema-validation/ for more information about document
// validation.
func (b *BulkWriteOptionsBuilder) SetBypassDocumentValidation(bypass bool) *BulkWriteOptionsBuilder {
b.Opts = append(b.Opts, func(opts *BulkWriteOptions) error {
opts.BypassDocumentValidation = &bypass
Expand Down
Loading
Loading