seba-365 - implemented dep
Change-Id: Ia6226d50e7615935a0c8876809a687427ff88c22
diff --git a/vendor/github.com/mongodb/mongo-go-driver/mongo/options/aggregateoptions.go b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/aggregateoptions.go
new file mode 100644
index 0000000..3700d84
--- /dev/null
+++ b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/aggregateoptions.go
@@ -0,0 +1,119 @@
+// Copyright (C) MongoDB, Inc. 2017-present.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+
+package options
+
+import "time"
+
+// AggregateOptions represents all possible options to the aggregate() function
+type AggregateOptions struct {
+ AllowDiskUse *bool // Enables writing to temporary files. When set to true, aggregation stages can write data to the _tmp subdirectory in the dbPath directory
+ BatchSize *int32 // The number of documents to return per batch
+ BypassDocumentValidation *bool // If true, allows the write to opt-out of document level validation. This only applies when the $out stage is specified
+ Collation *Collation // Specifies a collation
+ MaxTime *time.Duration // The maximum amount of time to allow the query to run
+ MaxAwaitTime *time.Duration // The maximum amount of time for the server to wait on new documents to satisfy a tailable cursor query
+ Comment *string // Enables users to specify an arbitrary string to help trace the operation through the database profiler, currentOp and logs.
+ Hint interface{} // The index to use for the aggregation. The hint does not apply to $lookup and $graphLookup stages
+}
+
+// Aggregate returns a pointer to a new AggregateOptions
+func Aggregate() *AggregateOptions {
+ return &AggregateOptions{}
+}
+
+// SetAllowDiskUse enables writing to temporary files. When set to true,
+// aggregation stages can write data to the _tmp subdirectory in the
+// dbPath directory
+func (ao *AggregateOptions) SetAllowDiskUse(b bool) *AggregateOptions {
+ ao.AllowDiskUse = &b
+ return ao
+}
+
+// SetBatchSize specifies the number of documents to return per batch
+func (ao *AggregateOptions) SetBatchSize(i int32) *AggregateOptions {
+ ao.BatchSize = &i
+ return ao
+}
+
+// SetBypassDocumentValidation allows the write to opt-out of document level
+// validation. This only applies when the $out stage is specified
+// Valid for server versions >= 3.2. For servers < 3.2, this option is ignored.
+func (ao *AggregateOptions) SetBypassDocumentValidation(b bool) *AggregateOptions {
+ ao.BypassDocumentValidation = &b
+ return ao
+}
+
+// SetCollation specifies a collation.
+// Valid for server versions >= 3.4
+func (ao *AggregateOptions) SetCollation(c *Collation) *AggregateOptions {
+ ao.Collation = c
+ return ao
+}
+
+// SetMaxTime specifies the maximum amount of time to allow the query to run
+func (ao *AggregateOptions) SetMaxTime(d time.Duration) *AggregateOptions {
+ ao.MaxTime = &d
+ return ao
+}
+
+// SetMaxAwaitTime specifies the maximum amount of time for the server to
+// wait on new documents to satisfy a tailable cursor query
+// For servers < 3.2, this option is ignored
+func (ao *AggregateOptions) SetMaxAwaitTime(d time.Duration) *AggregateOptions {
+ ao.MaxAwaitTime = &d
+ return ao
+}
+
+// SetComment enables users to specify an arbitrary string to help trace the
+// operation through the database profiler, currentOp and logs.
+func (ao *AggregateOptions) SetComment(s string) *AggregateOptions {
+ ao.Comment = &s
+ return ao
+}
+
+// SetHint specifies the index to use for the aggregation. The hint does not
+// apply to $lookup and $graphLookup stages
+func (ao *AggregateOptions) SetHint(h interface{}) *AggregateOptions {
+ ao.Hint = h
+ return ao
+}
+
+// MergeAggregateOptions combines the argued AggregateOptions into a single AggregateOptions in a last-one-wins fashion
+func MergeAggregateOptions(opts ...*AggregateOptions) *AggregateOptions {
+ aggOpts := Aggregate()
+ for _, ao := range opts {
+ if ao == nil {
+ continue
+ }
+ if ao.AllowDiskUse != nil {
+ aggOpts.AllowDiskUse = ao.AllowDiskUse
+ }
+ if ao.BatchSize != nil {
+ aggOpts.BatchSize = ao.BatchSize
+ }
+ if ao.BypassDocumentValidation != nil {
+ aggOpts.BypassDocumentValidation = ao.BypassDocumentValidation
+ }
+ if ao.Collation != nil {
+ aggOpts.Collation = ao.Collation
+ }
+ if ao.MaxTime != nil {
+ aggOpts.MaxTime = ao.MaxTime
+ }
+ if ao.MaxAwaitTime != nil {
+ aggOpts.MaxAwaitTime = ao.MaxAwaitTime
+ }
+ if ao.Comment != nil {
+ aggOpts.Comment = ao.Comment
+ }
+ if ao.Hint != nil {
+ aggOpts.Hint = ao.Hint
+ }
+ }
+
+ return aggOpts
+}
diff --git a/vendor/github.com/mongodb/mongo-go-driver/mongo/options/bulkwriteoptions.go b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/bulkwriteoptions.go
new file mode 100644
index 0000000..86282fa
--- /dev/null
+++ b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/bulkwriteoptions.go
@@ -0,0 +1,55 @@
+// Copyright (C) MongoDB, Inc. 2017-present.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+
+package options
+
+// DefaultOrdered is the default order for a BulkWriteOptions struct created from BulkWrite.
+var DefaultOrdered = true
+
+// BulkWriteOptions represent all possible options for a bulkWrite operation.
+type BulkWriteOptions struct {
+ BypassDocumentValidation *bool // If true, allows the write to opt out of document-level validation.
+ Ordered *bool // If true, when a write fails, return without performing remaining writes. Defaults to true.
+}
+
+// BulkWrite creates a new *BulkWriteOptions
+func BulkWrite() *BulkWriteOptions {
+ return &BulkWriteOptions{
+ Ordered: &DefaultOrdered,
+ }
+}
+
+// SetOrdered configures the ordered option. If true, when a write fails, the function will return without attempting
+// remaining writes. Defaults to true.
+func (b *BulkWriteOptions) SetOrdered(ordered bool) *BulkWriteOptions {
+ b.Ordered = &ordered
+ return b
+}
+
+// SetBypassDocumentValidation specifies if the write should opt out of document-level validation.
+// Valid for server versions >= 3.2. For servers < 3.2, this option is ignored.
+func (b *BulkWriteOptions) SetBypassDocumentValidation(bypass bool) *BulkWriteOptions {
+ b.BypassDocumentValidation = &bypass
+ return b
+}
+
+// MergeBulkWriteOptions combines the given *BulkWriteOptions into a single *BulkWriteOptions in a last one wins fashion.
+func MergeBulkWriteOptions(opts ...*BulkWriteOptions) *BulkWriteOptions {
+ b := BulkWrite()
+ for _, opt := range opts {
+ if opt == nil {
+ continue
+ }
+ if opt.Ordered != nil {
+ b.Ordered = opt.Ordered
+ }
+ if opt.BypassDocumentValidation != nil {
+ b.BypassDocumentValidation = opt.BypassDocumentValidation
+ }
+ }
+
+ return b
+}
diff --git a/vendor/github.com/mongodb/mongo-go-driver/mongo/options/changestreamoptions.go b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/changestreamoptions.go
new file mode 100644
index 0000000..c8776ac
--- /dev/null
+++ b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/changestreamoptions.go
@@ -0,0 +1,97 @@
+// Copyright (C) MongoDB, Inc. 2017-present.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+
+package options
+
+import (
+ "github.com/mongodb/mongo-go-driver/bson/primitive"
+ "time"
+)
+
+// ChangeStreamOptions represents all possible options to a change stream
+type ChangeStreamOptions struct {
+ BatchSize *int32 // The number of documents to return per batch
+ Collation *Collation // Specifies a collation
+ FullDocument *FullDocument // When set to ‘updateLookup’, the change notification for partial updates will include both a delta describing the changes to the document, as well as a copy of the entire document that was changed from some time after the change occurred.
+ MaxAwaitTime *time.Duration // The maximum amount of time for the server to wait on new documents to satisfy a change stream query
+ ResumeAfter interface{} // Specifies the logical starting point for the new change stream
+ StartAtOperationTime *primitive.Timestamp // Ensures that a change stream will only provide changes that occurred after a timestamp.
+}
+
+// ChangeStream returns a pointer to a new ChangeStreamOptions
+func ChangeStream() *ChangeStreamOptions {
+ return &ChangeStreamOptions{}
+}
+
+// SetBatchSize specifies the number of documents to return per batch
+func (cso *ChangeStreamOptions) SetBatchSize(i int32) *ChangeStreamOptions {
+ cso.BatchSize = &i
+ return cso
+}
+
+// SetCollation specifies a collation
+func (cso *ChangeStreamOptions) SetCollation(c Collation) *ChangeStreamOptions {
+ cso.Collation = &c
+ return cso
+}
+
+// SetFullDocument specifies the fullDocument option.
+// When set to ‘updateLookup’, the change notification for partial updates will
+// include both a delta describing the changes to the document, as well as a
+// copy of the entire document that was changed from some time after the change
+// occurred.
+func (cso *ChangeStreamOptions) SetFullDocument(fd FullDocument) *ChangeStreamOptions {
+ cso.FullDocument = &fd
+ return cso
+}
+
+// SetMaxAwaitTime specifies the maximum amount of time for the server to wait on new documents to satisfy a change stream query
+func (cso *ChangeStreamOptions) SetMaxAwaitTime(d time.Duration) *ChangeStreamOptions {
+ cso.MaxAwaitTime = &d
+ return cso
+}
+
+// SetResumeAfter specifies the logical starting point for the new change stream
+func (cso *ChangeStreamOptions) SetResumeAfter(rt interface{}) *ChangeStreamOptions {
+ cso.ResumeAfter = rt
+ return cso
+}
+
+// SetStartAtOperationTime ensures that a change stream will only provide changes that occurred after a specified timestamp.
+func (cso *ChangeStreamOptions) SetStartAtOperationTime(t *primitive.Timestamp) *ChangeStreamOptions {
+ cso.StartAtOperationTime = t
+ return cso
+}
+
+// MergeChangeStreamOptions combines the argued ChangeStreamOptions into a single ChangeStreamOptions in a last-one-wins fashion
+func MergeChangeStreamOptions(opts ...*ChangeStreamOptions) *ChangeStreamOptions {
+ csOpts := ChangeStream()
+ for _, cso := range opts {
+ if cso == nil {
+ continue
+ }
+ if cso.BatchSize != nil {
+ csOpts.BatchSize = cso.BatchSize
+ }
+ if cso.Collation != nil {
+ csOpts.Collation = cso.Collation
+ }
+ if cso.FullDocument != nil {
+ csOpts.FullDocument = cso.FullDocument
+ }
+ if cso.MaxAwaitTime != nil {
+ csOpts.MaxAwaitTime = cso.MaxAwaitTime
+ }
+ if cso.ResumeAfter != nil {
+ csOpts.ResumeAfter = cso.ResumeAfter
+ }
+ if cso.StartAtOperationTime != nil {
+ csOpts.StartAtOperationTime = cso.StartAtOperationTime
+ }
+ }
+
+ return csOpts
+}
diff --git a/vendor/github.com/mongodb/mongo-go-driver/mongo/options/clientoptions.go b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/clientoptions.go
new file mode 100644
index 0000000..e09a9c1
--- /dev/null
+++ b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/clientoptions.go
@@ -0,0 +1,424 @@
+// Copyright (C) MongoDB, Inc. 2017-present.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+
+package options
+
+import (
+ "context"
+ "net"
+ "time"
+
+ "github.com/mongodb/mongo-go-driver/bson/bsoncodec"
+ "github.com/mongodb/mongo-go-driver/event"
+ "github.com/mongodb/mongo-go-driver/mongo/readconcern"
+ "github.com/mongodb/mongo-go-driver/mongo/readpref"
+ "github.com/mongodb/mongo-go-driver/mongo/writeconcern"
+ "github.com/mongodb/mongo-go-driver/x/mongo/driver/topology"
+ "github.com/mongodb/mongo-go-driver/x/network/connection"
+ "github.com/mongodb/mongo-go-driver/x/network/connstring"
+)
+
+// ContextDialer makes new network connections
+type ContextDialer interface {
+ DialContext(ctx context.Context, network, address string) (net.Conn, error)
+}
+
+// SSLOpt holds client SSL options.
+//
+// Enabled indicates whether SSL should be enabled.
+//
+// ClientCertificateKeyFile specifies the file containing the client certificate and private key
+// used for authentication.
+//
+// ClientCertificateKeyPassword provides a callback that returns a password used for decrypting the
+// private key of a PEM file (if one is provided).
+//
+// Insecure indicates whether to skip the verification of the server certificate and hostname.
+//
+// CaFile specifies the file containing the certificate authority used for SSL connections.
+type SSLOpt struct {
+ Enabled bool
+ ClientCertificateKeyFile string
+ ClientCertificateKeyPassword func() string
+ Insecure bool
+ CaFile string
+}
+
+// Credential holds auth options.
+//
+// AuthMechanism indicates the mechanism to use for authentication.
+// Supported values include "SCRAM-SHA-256", "SCRAM-SHA-1", "MONGODB-CR", "PLAIN", "GSSAPI", and "MONGODB-X509".
+//
+// AuthMechanismProperties specifies additional configuration options which may be used by certain
+// authentication mechanisms.
+//
+// AuthSource specifies the database to authenticate against.
+//
+// Username specifies the username that will be authenticated.
+//
+// Password specifies the password used for authentication.
+type Credential struct {
+ AuthMechanism string
+ AuthMechanismProperties map[string]string
+ AuthSource string
+ Username string
+ Password string
+}
+
+// ClientOptions represents all possbile options to configure a client.
+type ClientOptions struct {
+ TopologyOptions []topology.Option
+ ConnString connstring.ConnString
+ RetryWrites *bool
+ ReadPreference *readpref.ReadPref
+ ReadConcern *readconcern.ReadConcern
+ WriteConcern *writeconcern.WriteConcern
+ Registry *bsoncodec.Registry
+}
+
+// Client creates a new ClientOptions instance.
+func Client() *ClientOptions {
+ return &ClientOptions{
+ TopologyOptions: make([]topology.Option, 0),
+ }
+}
+
+// SetAppName specifies the client application name. This value is used by MongoDB when it logs
+// connection information and profile information, such as slow queries.
+func (c *ClientOptions) SetAppName(s string) *ClientOptions {
+ c.ConnString.AppName = s
+
+ return c
+}
+
+// SetAuth sets the authentication options.
+func (c *ClientOptions) SetAuth(auth Credential) *ClientOptions {
+ c.ConnString.AuthMechanism = auth.AuthMechanism
+ c.ConnString.AuthMechanismProperties = auth.AuthMechanismProperties
+ c.ConnString.AuthSource = auth.AuthSource
+ c.ConnString.Username = auth.Username
+ c.ConnString.Password = auth.Password
+
+ return c
+}
+
+// SetConnectTimeout specifies the timeout for an initial connection to a server.
+// If a custom Dialer is used, this method won't be set and the user is
+// responsible for setting the ConnectTimeout for connections on the dialer
+// themselves.
+func (c *ClientOptions) SetConnectTimeout(d time.Duration) *ClientOptions {
+ c.ConnString.ConnectTimeout = d
+ c.ConnString.ConnectTimeoutSet = true
+
+ return c
+}
+
+// SetDialer specifies a custom dialer used to dial new connections to a server.
+// If a custom dialer is not set, a net.Dialer with a 300 second keepalive time will be used by default.
+func (c *ClientOptions) SetDialer(d ContextDialer) *ClientOptions {
+ c.TopologyOptions = append(
+ c.TopologyOptions,
+ topology.WithServerOptions(func(opts ...topology.ServerOption) []topology.ServerOption {
+ return append(
+ opts,
+ topology.WithConnectionOptions(func(opts ...connection.Option) []connection.Option {
+ return append(
+ opts,
+ connection.WithDialer(func(connection.Dialer) connection.Dialer {
+ return d
+ }),
+ )
+ }),
+ )
+ }),
+ )
+
+ return c
+}
+
+// SetMonitor specifies a command monitor used to see commands for a client.
+func (c *ClientOptions) SetMonitor(m *event.CommandMonitor) *ClientOptions {
+ c.TopologyOptions = append(
+ c.TopologyOptions,
+ topology.WithServerOptions(func(opts ...topology.ServerOption) []topology.ServerOption {
+ return append(
+ opts,
+ topology.WithConnectionOptions(func(opts ...connection.Option) []connection.Option {
+ return append(
+ opts,
+ connection.WithMonitor(func(*event.CommandMonitor) *event.CommandMonitor {
+ return m
+ }),
+ )
+ }),
+ )
+ }),
+ )
+
+ return c
+}
+
+// SetHeartbeatInterval specifies the interval to wait between server monitoring checks.
+func (c *ClientOptions) SetHeartbeatInterval(d time.Duration) *ClientOptions {
+ c.ConnString.HeartbeatInterval = d
+ c.ConnString.HeartbeatIntervalSet = true
+
+ return c
+}
+
+// SetHosts specifies the initial list of addresses from which to discover the rest of the cluster.
+func (c *ClientOptions) SetHosts(s []string) *ClientOptions {
+ c.ConnString.Hosts = s
+
+ return c
+}
+
+// SetLocalThreshold specifies how far to distribute queries, beyond the server with the fastest
+// round-trip time. If a server's roundtrip time is more than LocalThreshold slower than the
+// the fastest, the driver will not send queries to that server.
+func (c *ClientOptions) SetLocalThreshold(d time.Duration) *ClientOptions {
+ c.ConnString.LocalThreshold = d
+ c.ConnString.LocalThresholdSet = true
+
+ return c
+}
+
+// SetMaxConnIdleTime specifies the maximum number of milliseconds that a connection can remain idle
+// in a connection pool before being removed and closed.
+func (c *ClientOptions) SetMaxConnIdleTime(d time.Duration) *ClientOptions {
+ c.ConnString.MaxConnIdleTime = d
+ c.ConnString.MaxConnIdleTimeSet = true
+
+ return c
+}
+
+// SetMaxPoolSize specifies the max size of a server's connection pool.
+func (c *ClientOptions) SetMaxPoolSize(u uint16) *ClientOptions {
+ c.ConnString.MaxPoolSize = u
+ c.ConnString.MaxPoolSizeSet = true
+
+ return c
+}
+
+// SetReadConcern specifies the read concern.
+func (c *ClientOptions) SetReadConcern(rc *readconcern.ReadConcern) *ClientOptions {
+ c.ReadConcern = rc
+
+ return c
+}
+
+// SetReadPreference specifies the read preference.
+func (c *ClientOptions) SetReadPreference(rp *readpref.ReadPref) *ClientOptions {
+ c.ReadPreference = rp
+
+ return c
+}
+
+// SetRegistry specifies the bsoncodec.Registry.
+func (c *ClientOptions) SetRegistry(registry *bsoncodec.Registry) *ClientOptions {
+ c.Registry = registry
+
+ // add registry to the server options so that it will be used for the cursors built by this client
+ c.TopologyOptions = append(
+ c.TopologyOptions,
+ topology.WithServerOptions(func(opts ...topology.ServerOption) []topology.ServerOption {
+ return append(
+ opts,
+ topology.WithRegistry(func(*bsoncodec.Registry) *bsoncodec.Registry {
+ return registry
+ }),
+ )
+ }),
+ )
+
+ return c
+}
+
+// SetReplicaSet specifies the name of the replica set of the cluster.
+func (c *ClientOptions) SetReplicaSet(s string) *ClientOptions {
+ c.ConnString.ReplicaSet = s
+
+ return c
+}
+
+// SetRetryWrites specifies whether the client has retryable writes enabled.
+func (c *ClientOptions) SetRetryWrites(b bool) *ClientOptions {
+ c.RetryWrites = &b
+
+ return c
+}
+
+// SetServerSelectionTimeout specifies a timeout in milliseconds to block for server selection.
+func (c *ClientOptions) SetServerSelectionTimeout(d time.Duration) *ClientOptions {
+ c.ConnString.ServerSelectionTimeout = d
+ c.ConnString.ServerSelectionTimeoutSet = true
+
+ return c
+}
+
+// SetSingle specifies whether the driver should connect directly to the server instead of
+// auto-discovering other servers in the cluster.
+func (c *ClientOptions) SetSingle(b bool) *ClientOptions {
+ if b {
+ c.ConnString.Connect = connstring.SingleConnect
+ } else {
+ c.ConnString.Connect = connstring.AutoConnect
+ }
+ c.ConnString.ConnectSet = true
+
+ return c
+}
+
+// SetSocketTimeout specifies the time in milliseconds to attempt to send or receive on a socket
+// before the attempt times out.
+func (c *ClientOptions) SetSocketTimeout(d time.Duration) *ClientOptions {
+ c.ConnString.SocketTimeout = d
+ c.ConnString.SocketTimeoutSet = true
+
+ return c
+}
+
+// SetSSL sets SSL options.
+func (c *ClientOptions) SetSSL(ssl *SSLOpt) *ClientOptions {
+ c.ConnString.SSL = ssl.Enabled
+ c.ConnString.SSLSet = true
+
+ if ssl.ClientCertificateKeyFile != "" {
+ c.ConnString.SSLClientCertificateKeyFile = ssl.ClientCertificateKeyFile
+ c.ConnString.SSLClientCertificateKeyFileSet = true
+ }
+
+ if ssl.ClientCertificateKeyPassword != nil {
+ c.ConnString.SSLClientCertificateKeyPassword = ssl.ClientCertificateKeyPassword
+ c.ConnString.SSLClientCertificateKeyPasswordSet = true
+ }
+
+ c.ConnString.SSLInsecure = ssl.Insecure
+ c.ConnString.SSLInsecureSet = true
+
+ if ssl.CaFile != "" {
+ c.ConnString.SSLCaFile = ssl.CaFile
+ c.ConnString.SSLCaFileSet = true
+ }
+
+ return c
+}
+
+// SetWriteConcern sets the write concern.
+func (c *ClientOptions) SetWriteConcern(wc *writeconcern.WriteConcern) *ClientOptions {
+ c.WriteConcern = wc
+
+ return c
+}
+
+// MergeClientOptions combines the given connstring and *ClientOptions into a single *ClientOptions in a last one wins
+// fashion. The given connstring will be used for the default options, which can be overwritten using the given
+// *ClientOptions.
+func MergeClientOptions(cs connstring.ConnString, opts ...*ClientOptions) *ClientOptions {
+ c := Client()
+ c.ConnString = cs
+
+ for _, opt := range opts {
+ if opt == nil {
+ continue
+ }
+ c.TopologyOptions = append(c.TopologyOptions, opt.TopologyOptions...)
+
+ if an := opt.ConnString.AppName; an != "" {
+ c.ConnString.AppName = an
+ }
+ if am := opt.ConnString.AuthMechanism; len(am) != 0 {
+ c.ConnString.AuthMechanism = am
+ }
+ if amp := opt.ConnString.AuthMechanismProperties; amp != nil {
+ c.ConnString.AuthMechanismProperties = amp
+ }
+ if as := opt.ConnString.AuthSource; len(as) != 0 {
+ c.ConnString.AuthSource = as
+ }
+ if u := opt.ConnString.Username; len(u) != 0 {
+ c.ConnString.Username = u
+ }
+ if p := opt.ConnString.Password; len(p) != 0 {
+ c.ConnString.Password = p
+ }
+ if opt.ConnString.ConnectTimeoutSet {
+ c.ConnString.ConnectTimeoutSet = true
+ c.ConnString.ConnectTimeout = opt.ConnString.ConnectTimeout
+ }
+ if opt.ConnString.HeartbeatIntervalSet {
+ c.ConnString.HeartbeatIntervalSet = true
+ c.ConnString.HeartbeatInterval = opt.ConnString.HeartbeatInterval
+ }
+ if h := opt.ConnString.Hosts; h != nil {
+ c.ConnString.Hosts = h
+ }
+ if opt.ConnString.LocalThresholdSet {
+ c.ConnString.LocalThresholdSet = true
+ c.ConnString.LocalThreshold = opt.ConnString.LocalThreshold
+ }
+ if opt.ConnString.MaxConnIdleTimeSet {
+ c.ConnString.MaxConnIdleTimeSet = true
+ c.ConnString.MaxConnIdleTime = opt.ConnString.MaxConnIdleTime
+ }
+ if opt.ConnString.MaxPoolSizeSet {
+ c.ConnString.MaxPoolSizeSet = true
+ c.ConnString.MaxPoolSize = opt.ConnString.MaxPoolSize
+ }
+ if opt.ReadConcern != nil {
+ c.ReadConcern = opt.ReadConcern
+ }
+ if opt.ReadPreference != nil {
+ c.ReadPreference = opt.ReadPreference
+ }
+ if opt.Registry != nil {
+ c.Registry = opt.Registry
+ }
+ if rs := opt.ConnString.ReplicaSet; rs != "" {
+ c.ConnString.ReplicaSet = rs
+ }
+ if opt.RetryWrites != nil {
+ c.RetryWrites = opt.RetryWrites
+ }
+ if opt.ConnString.ServerSelectionTimeoutSet {
+ c.ConnString.ServerSelectionTimeoutSet = true
+ c.ConnString.ServerSelectionTimeout = opt.ConnString.ServerSelectionTimeout
+ }
+ if opt.ConnString.ConnectSet {
+ c.ConnString.ConnectSet = true
+ c.ConnString.Connect = opt.ConnString.Connect
+ }
+ if opt.ConnString.SocketTimeoutSet {
+ c.ConnString.SocketTimeoutSet = true
+ c.ConnString.SocketTimeout = opt.ConnString.SocketTimeout
+ }
+ if opt.ConnString.SSLSet {
+ c.ConnString.SSLSet = true
+ c.ConnString.SSL = opt.ConnString.SSL
+ }
+ if opt.ConnString.SSLClientCertificateKeyFileSet {
+ c.ConnString.SSLClientCertificateKeyFileSet = true
+ c.ConnString.SSLClientCertificateKeyFile = opt.ConnString.SSLClientCertificateKeyFile
+ }
+ if opt.ConnString.SSLClientCertificateKeyPasswordSet {
+ c.ConnString.SSLClientCertificateKeyPasswordSet = true
+ c.ConnString.SSLClientCertificateKeyPassword = opt.ConnString.SSLClientCertificateKeyPassword
+ }
+ if opt.ConnString.SSLInsecureSet {
+ c.ConnString.SSLInsecureSet = true
+ c.ConnString.SSLInsecure = opt.ConnString.SSLInsecure
+ }
+ if opt.ConnString.SSLCaFileSet {
+ c.ConnString.SSLCaFileSet = true
+ c.ConnString.SSLCaFile = opt.ConnString.SSLCaFile
+ }
+ if opt.WriteConcern != nil {
+ c.WriteConcern = opt.WriteConcern
+ }
+ }
+
+ return c
+}
diff --git a/vendor/github.com/mongodb/mongo-go-driver/mongo/options/collectionoptions.go b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/collectionoptions.go
new file mode 100644
index 0000000..3415505
--- /dev/null
+++ b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/collectionoptions.go
@@ -0,0 +1,77 @@
+// Copyright (C) MongoDB, Inc. 2017-present.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+
+package options
+
+import (
+ "github.com/mongodb/mongo-go-driver/bson/bsoncodec"
+ "github.com/mongodb/mongo-go-driver/mongo/readconcern"
+ "github.com/mongodb/mongo-go-driver/mongo/readpref"
+ "github.com/mongodb/mongo-go-driver/mongo/writeconcern"
+)
+
+// CollectionOptions represent all possible options to configure a Collection.
+type CollectionOptions struct {
+ ReadConcern *readconcern.ReadConcern // The read concern for operations in the collection.
+ WriteConcern *writeconcern.WriteConcern // The write concern for operations in the collection.
+ ReadPreference *readpref.ReadPref // The read preference for operations in the collection.
+ Registry *bsoncodec.Registry // The registry to be used to construct BSON encoders and decoders for the collection.
+}
+
+// Collection creates a new CollectionOptions instance
+func Collection() *CollectionOptions {
+ return &CollectionOptions{}
+}
+
+// SetReadConcern sets the read concern for the collection.
+func (c *CollectionOptions) SetReadConcern(rc *readconcern.ReadConcern) *CollectionOptions {
+ c.ReadConcern = rc
+ return c
+}
+
+// SetWriteConcern sets the write concern for the collection.
+func (c *CollectionOptions) SetWriteConcern(wc *writeconcern.WriteConcern) *CollectionOptions {
+ c.WriteConcern = wc
+ return c
+}
+
+// SetReadPreference sets the read preference for the collection.
+func (c *CollectionOptions) SetReadPreference(rp *readpref.ReadPref) *CollectionOptions {
+ c.ReadPreference = rp
+ return c
+}
+
+// SetRegistry sets the bsoncodec Registry for the collection.
+func (c *CollectionOptions) SetRegistry(r *bsoncodec.Registry) *CollectionOptions {
+ c.Registry = r
+ return c
+}
+
+// MergeCollectionOptions combines the *CollectionOptions arguments into a single *CollectionOptions in a last one wins
+// fashion.
+func MergeCollectionOptions(opts ...*CollectionOptions) *CollectionOptions {
+ c := Collection()
+
+ for _, opt := range opts {
+ if opt == nil {
+ continue
+ }
+ if opt.ReadConcern != nil {
+ c.ReadConcern = opt.ReadConcern
+ }
+ if opt.WriteConcern != nil {
+ c.WriteConcern = opt.WriteConcern
+ }
+ if opt.ReadPreference != nil {
+ c.ReadPreference = opt.ReadPreference
+ }
+ if opt.Registry != nil {
+ c.Registry = opt.Registry
+ }
+ }
+
+ return c
+}
diff --git a/vendor/github.com/mongodb/mongo-go-driver/mongo/options/countoptions.go b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/countoptions.go
new file mode 100644
index 0000000..be3baab
--- /dev/null
+++ b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/countoptions.go
@@ -0,0 +1,81 @@
+// Copyright (C) MongoDB, Inc. 2017-present.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+
+package options
+
+import "time"
+
+// CountOptions represents all possible options to the count() function
+type CountOptions struct {
+ Collation *Collation // Specifies a collation
+ Hint interface{} // The index to use
+ Limit *int64 // The maximum number of documents to count
+ MaxTime *time.Duration // The maximum amount of time to allow the operation to run
+ Skip *int64 // The number of documents to skip before counting
+}
+
+// Count returns a pointer to a new CountOptions
+func Count() *CountOptions {
+ return &CountOptions{}
+}
+
+// SetCollation specifies a collation
+// Valid for server versions >= 3.4
+func (co *CountOptions) SetCollation(c *Collation) *CountOptions {
+ co.Collation = c
+ return co
+}
+
+// SetHint specifies the index to use
+func (co *CountOptions) SetHint(h interface{}) *CountOptions {
+ co.Hint = h
+ return co
+}
+
+// SetLimit specifies the maximum number of documents to count
+func (co *CountOptions) SetLimit(i int64) *CountOptions {
+ co.Limit = &i
+ return co
+}
+
+// SetMaxTime specifies the maximum amount of time to allow the operation to run
+func (co *CountOptions) SetMaxTime(d time.Duration) *CountOptions {
+ co.MaxTime = &d
+ return co
+}
+
+// SetSkip specifies the number of documents to skip before counting
+func (co *CountOptions) SetSkip(i int64) *CountOptions {
+ co.Skip = &i
+ return co
+}
+
+// MergeCountOptions combines the argued CountOptions into a single CountOptions in a last-one-wins fashion
+func MergeCountOptions(opts ...*CountOptions) *CountOptions {
+ countOpts := Count()
+ for _, co := range opts {
+ if co == nil {
+ continue
+ }
+ if co.Collation != nil {
+ countOpts.Collation = co.Collation
+ }
+ if co.Hint != nil {
+ countOpts.Hint = co.Hint
+ }
+ if co.Limit != nil {
+ countOpts.Limit = co.Limit
+ }
+ if co.MaxTime != nil {
+ countOpts.MaxTime = co.MaxTime
+ }
+ if co.Skip != nil {
+ countOpts.Skip = co.Skip
+ }
+ }
+
+ return countOpts
+}
diff --git a/vendor/github.com/mongodb/mongo-go-driver/mongo/options/dboptions.go b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/dboptions.go
new file mode 100644
index 0000000..989cb13
--- /dev/null
+++ b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/dboptions.go
@@ -0,0 +1,77 @@
+// Copyright (C) MongoDB, Inc. 2017-present.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+
+package options
+
+import (
+ "github.com/mongodb/mongo-go-driver/bson/bsoncodec"
+ "github.com/mongodb/mongo-go-driver/mongo/readconcern"
+ "github.com/mongodb/mongo-go-driver/mongo/readpref"
+ "github.com/mongodb/mongo-go-driver/mongo/writeconcern"
+)
+
+// DatabaseOptions represent all possible options to configure a Database.
+type DatabaseOptions struct {
+ ReadConcern *readconcern.ReadConcern // The read concern for operations in the database.
+ WriteConcern *writeconcern.WriteConcern // The write concern for operations in the database.
+ ReadPreference *readpref.ReadPref // The read preference for operations in the database.
+ Registry *bsoncodec.Registry // The registry to be used to construct BSON encoders and decoders for the database.
+}
+
+// Database creates a new DatabaseOptions instance
+func Database() *DatabaseOptions {
+ return &DatabaseOptions{}
+}
+
+// SetReadConcern sets the read concern for the database.
+func (d *DatabaseOptions) SetReadConcern(rc *readconcern.ReadConcern) *DatabaseOptions {
+ d.ReadConcern = rc
+ return d
+}
+
+// SetWriteConcern sets the write concern for the database.
+func (d *DatabaseOptions) SetWriteConcern(wc *writeconcern.WriteConcern) *DatabaseOptions {
+ d.WriteConcern = wc
+ return d
+}
+
+// SetReadPreference sets the read preference for the database.
+func (d *DatabaseOptions) SetReadPreference(rp *readpref.ReadPref) *DatabaseOptions {
+ d.ReadPreference = rp
+ return d
+}
+
+// SetRegistry sets the bsoncodec Registry for the database.
+func (d *DatabaseOptions) SetRegistry(r *bsoncodec.Registry) *DatabaseOptions {
+ d.Registry = r
+ return d
+}
+
+// MergeDatabaseOptions combines the *DatabaseOptions arguments into a single *DatabaseOptions in a last one wins
+// fashion.
+func MergeDatabaseOptions(opts ...*DatabaseOptions) *DatabaseOptions {
+ d := Database()
+
+ for _, opt := range opts {
+ if opt == nil {
+ continue
+ }
+ if opt.ReadConcern != nil {
+ d.ReadConcern = opt.ReadConcern
+ }
+ if opt.WriteConcern != nil {
+ d.WriteConcern = opt.WriteConcern
+ }
+ if opt.ReadPreference != nil {
+ d.ReadPreference = opt.ReadPreference
+ }
+ if opt.Registry != nil {
+ d.Registry = opt.Registry
+ }
+ }
+
+ return d
+}
diff --git a/vendor/github.com/mongodb/mongo-go-driver/mongo/options/deleteoptions.go b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/deleteoptions.go
new file mode 100644
index 0000000..919d6b8
--- /dev/null
+++ b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/deleteoptions.go
@@ -0,0 +1,39 @@
+// Copyright (C) MongoDB, Inc. 2017-present.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+
+package options
+
+// DeleteOptions represents all possible options to the deleteOne() and deleteMany() functions
+type DeleteOptions struct {
+ Collation *Collation // Specifies a collation
+}
+
+// Delete returns a pointer to a new DeleteOptions
+func Delete() *DeleteOptions {
+ return &DeleteOptions{}
+}
+
+// SetCollation specifies a collation
+// Valid for servers >= 3.4.
+func (do *DeleteOptions) SetCollation(c *Collation) *DeleteOptions {
+ do.Collation = c
+ return do
+}
+
+// MergeDeleteOptions combines the argued DeleteOptions into a single DeleteOptions in a last-one-wins fashion
+func MergeDeleteOptions(opts ...*DeleteOptions) *DeleteOptions {
+ dOpts := Delete()
+ for _, do := range opts {
+ if do == nil {
+ continue
+ }
+ if do.Collation != nil {
+ dOpts.Collation = do.Collation
+ }
+ }
+
+ return dOpts
+}
diff --git a/vendor/github.com/mongodb/mongo-go-driver/mongo/options/distinctoptions.go b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/distinctoptions.go
new file mode 100644
index 0000000..3b3f588
--- /dev/null
+++ b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/distinctoptions.go
@@ -0,0 +1,51 @@
+// Copyright (C) MongoDB, Inc. 2017-present.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+
+package options
+
+import "time"
+
+// DistinctOptions represents all possible options to the distinct() function
+type DistinctOptions struct {
+ Collation *Collation // Specifies a collation
+ MaxTime *time.Duration // The maximum amount of time to allow the operation to run
+}
+
+// Distinct returns a pointer to a new DistinctOptions
+func Distinct() *DistinctOptions {
+ return &DistinctOptions{}
+}
+
+// SetCollation specifies a collation
+// Valid for server versions >= 3.4
+func (do *DistinctOptions) SetCollation(c *Collation) *DistinctOptions {
+ do.Collation = c
+ return do
+}
+
+// SetMaxTime specifies the maximum amount of time to allow the operation to run
+func (do *DistinctOptions) SetMaxTime(d time.Duration) *DistinctOptions {
+ do.MaxTime = &d
+ return do
+}
+
+// MergeDistinctOptions combines the argued DistinctOptions into a single DistinctOptions in a last-one-wins fashion
+func MergeDistinctOptions(opts ...*DistinctOptions) *DistinctOptions {
+ distinctOpts := Distinct()
+ for _, do := range opts {
+ if do == nil {
+ continue
+ }
+ if do.Collation != nil {
+ distinctOpts.Collation = do.Collation
+ }
+ if do.MaxTime != nil {
+ distinctOpts.MaxTime = do.MaxTime
+ }
+ }
+
+ return distinctOpts
+}
diff --git a/vendor/github.com/mongodb/mongo-go-driver/mongo/options/estimatedcountoptions.go b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/estimatedcountoptions.go
new file mode 100644
index 0000000..f43bb9f
--- /dev/null
+++ b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/estimatedcountoptions.go
@@ -0,0 +1,42 @@
+// Copyright (C) MongoDB, Inc. 2017-present.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+
+package options
+
+import "time"
+
+// EstimatedDocumentCountOptions represents all possible options to the estimatedDocumentCount() function
+type EstimatedDocumentCountOptions struct {
+ MaxTime *time.Duration // The maximum amount of time to allow the operation to run
+}
+
+// EstimatedDocumentCount returns a pointer to a new EstimatedDocumentCountOptions
+func EstimatedDocumentCount() *EstimatedDocumentCountOptions {
+ return &EstimatedDocumentCountOptions{}
+}
+
+// SetMaxTime specifies the maximum amount of time to allow the operation to run
+func (eco *EstimatedDocumentCountOptions) SetMaxTime(d time.Duration) *EstimatedDocumentCountOptions {
+ eco.MaxTime = &d
+ return eco
+}
+
+// MergeEstimatedDocumentCountOptions combines the given *EstimatedDocumentCountOptions into a single
+// *EstimatedDocumentCountOptions in a last one wins fashion.
+func MergeEstimatedDocumentCountOptions(opts ...*EstimatedDocumentCountOptions) *EstimatedDocumentCountOptions {
+ e := EstimatedDocumentCount()
+ for _, opt := range opts {
+ if opt == nil {
+ continue
+ }
+
+ if opt.MaxTime != nil {
+ e.MaxTime = opt.MaxTime
+ }
+ }
+
+ return e
+}
diff --git a/vendor/github.com/mongodb/mongo-go-driver/mongo/options/findoptions.go b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/findoptions.go
new file mode 100644
index 0000000..4ba6133
--- /dev/null
+++ b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/findoptions.go
@@ -0,0 +1,693 @@
+// Copyright (C) MongoDB, Inc. 2017-present.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+
+package options
+
+import (
+ "time"
+)
+
+// FindOptions represent all possible options to the find() function.
+type FindOptions struct {
+ AllowPartialResults *bool // If true, allows partial results to be returned if some shards are down.
+ BatchSize *int32 // Specifies the number of documents to return in every batch.
+ Collation *Collation // Specifies a collation to be used
+ Comment *string // Specifies a string to help trace the operation through the database.
+ CursorType *CursorType // Specifies the type of cursor to use
+ Hint interface{} // Specifies the index to use.
+ Limit *int64 // Sets a limit on the number of results to return.
+ Max interface{} // Sets an exclusive upper bound for a specific index
+ MaxAwaitTime *time.Duration // Specifies the maximum amount of time for the server to wait on new documents.
+ MaxTime *time.Duration // Specifies the maximum amount of time to allow the query to run.
+ Min interface{} // Specifies the inclusive lower bound for a specific index.
+ NoCursorTimeout *bool // If true, prevents cursors from timing out after an inactivity period.
+ OplogReplay *bool // Adds an option for internal use only and should not be set.
+ Projection interface{} // Limits the fields returned for all documents.
+ ReturnKey *bool // If true, only returns index keys for all result documents.
+ ShowRecordID *bool // If true, a $recordId field with the record identifier will be added to the returned documents.
+ Skip *int64 // Specifies the number of documents to skip before returning
+ Snapshot *bool // If true, prevents the cursor from returning a document more than once because of an intervening write operation.
+ Sort interface{} // Specifies the order in which to return results.
+}
+
+// Find creates a new FindOptions instance.
+func Find() *FindOptions {
+ return &FindOptions{}
+}
+
+// SetAllowPartialResults sets whether partial results can be returned if some shards are down.
+// For server versions < 3.2, this defaults to false.
+func (f *FindOptions) SetAllowPartialResults(b bool) *FindOptions {
+ f.AllowPartialResults = &b
+ return f
+}
+
+// SetBatchSize sets the number of documents to return in each batch.
+func (f *FindOptions) SetBatchSize(i int32) *FindOptions {
+ f.BatchSize = &i
+ return f
+}
+
+// SetCollation specifies a Collation to use for the Find operation.
+// Valid for server versions >= 3.4
+func (f *FindOptions) SetCollation(collation *Collation) *FindOptions {
+ f.Collation = collation
+ return f
+}
+
+// SetComment specifies a string to help trace the operation through the database.
+func (f *FindOptions) SetComment(comment string) *FindOptions {
+ f.Comment = &comment
+ return f
+}
+
+// SetCursorType specifes the type of cursor to use.
+func (f *FindOptions) SetCursorType(ct CursorType) *FindOptions {
+ f.CursorType = &ct
+ return f
+}
+
+// SetHint specifies the index to use.
+func (f *FindOptions) SetHint(hint interface{}) *FindOptions {
+ f.Hint = hint
+ return f
+}
+
+// SetLimit specifies a limit on the number of results.
+// A negative limit implies that only 1 batch should be returned.
+func (f *FindOptions) SetLimit(i int64) *FindOptions {
+ f.Limit = &i
+ return f
+}
+
+// SetMax specifies an exclusive upper bound for a specific index.
+func (f *FindOptions) SetMax(max interface{}) *FindOptions {
+ f.Max = max
+ return f
+}
+
+// SetMaxAwaitTime specifies the max amount of time for the server to wait on new documents.
+// If the cursor type is not TailableAwait, this option is ignored.
+// For server versions < 3.2, this option is ignored.
+func (f *FindOptions) SetMaxAwaitTime(d time.Duration) *FindOptions {
+ f.MaxAwaitTime = &d
+ return f
+}
+
+// SetMaxTime specifies the max time to allow the query to run.
+func (f *FindOptions) SetMaxTime(d time.Duration) *FindOptions {
+ f.MaxTime = &d
+ return f
+}
+
+// SetMin specifies the inclusive lower bound for a specific index.
+func (f *FindOptions) SetMin(min interface{}) *FindOptions {
+ f.Min = min
+ return f
+}
+
+// SetNoCursorTimeout specifies whether or not cursors should time out after a period of inactivity.
+// For server versions < 3.2, this defaults to false.
+func (f *FindOptions) SetNoCursorTimeout(b bool) *FindOptions {
+ f.NoCursorTimeout = &b
+ return f
+}
+
+// SetOplogReplay adds an option for internal use only and should not be set.
+// For server versions < 3.2, this defaults to false.
+func (f *FindOptions) SetOplogReplay(b bool) *FindOptions {
+ f.OplogReplay = &b
+ return f
+}
+
+// SetProjection adds an option to limit the fields returned for all documents.
+func (f *FindOptions) SetProjection(projection interface{}) *FindOptions {
+ f.Projection = projection
+ return f
+}
+
+// SetReturnKey adds an option to only return index keys for all result documents.
+func (f *FindOptions) SetReturnKey(b bool) *FindOptions {
+ f.ReturnKey = &b
+ return f
+}
+
+// SetShowRecordID adds an option to determine whether to return the record identifier for each document.
+// If true, a $recordId field will be added to each returned document.
+func (f *FindOptions) SetShowRecordID(b bool) *FindOptions {
+ f.ShowRecordID = &b
+ return f
+}
+
+// SetSkip specifies the number of documents to skip before returning.
+// For server versions < 3.2, this defaults to 0.
+func (f *FindOptions) SetSkip(i int64) *FindOptions {
+ f.Skip = &i
+ return f
+}
+
+// SetSnapshot prevents the cursor from returning a document more than once because of an intervening write operation.
+func (f *FindOptions) SetSnapshot(b bool) *FindOptions {
+ f.Snapshot = &b
+ return f
+}
+
+// SetSort specifies the order in which to return documents.
+func (f *FindOptions) SetSort(sort interface{}) *FindOptions {
+ f.Sort = sort
+ return f
+}
+
+// MergeFindOptions combines the argued FindOptions into a single FindOptions in a last-one-wins fashion
+func MergeFindOptions(opts ...*FindOptions) *FindOptions {
+ fo := Find()
+ for _, opt := range opts {
+ if opt == nil {
+ continue
+ }
+ if opt.AllowPartialResults != nil {
+ fo.AllowPartialResults = opt.AllowPartialResults
+ }
+ if opt.BatchSize != nil {
+ fo.BatchSize = opt.BatchSize
+ }
+ if opt.Collation != nil {
+ fo.Collation = opt.Collation
+ }
+ if opt.Comment != nil {
+ fo.Comment = opt.Comment
+ }
+ if opt.CursorType != nil {
+ fo.CursorType = opt.CursorType
+ }
+ if opt.Hint != nil {
+ fo.Hint = opt.Hint
+ }
+ if opt.Limit != nil {
+ fo.Limit = opt.Limit
+ }
+ if opt.Max != nil {
+ fo.Max = opt.Max
+ }
+ if opt.MaxAwaitTime != nil {
+ fo.MaxAwaitTime = opt.MaxAwaitTime
+ }
+ if opt.MaxTime != nil {
+ fo.MaxTime = opt.MaxTime
+ }
+ if opt.Min != nil {
+ fo.Min = opt.Min
+ }
+ if opt.NoCursorTimeout != nil {
+ fo.NoCursorTimeout = opt.NoCursorTimeout
+ }
+ if opt.OplogReplay != nil {
+ fo.OplogReplay = opt.OplogReplay
+ }
+ if opt.Projection != nil {
+ fo.Projection = opt.Projection
+ }
+ if opt.ReturnKey != nil {
+ fo.ReturnKey = opt.ReturnKey
+ }
+ if opt.ShowRecordID != nil {
+ fo.ShowRecordID = opt.ShowRecordID
+ }
+ if opt.Skip != nil {
+ fo.Skip = opt.Skip
+ }
+ if opt.Snapshot != nil {
+ fo.Snapshot = opt.Snapshot
+ }
+ if opt.Sort != nil {
+ fo.Sort = opt.Sort
+ }
+ }
+
+ return fo
+}
+
+// FindOneOptions represent all possible options to the findOne() function.
+type FindOneOptions struct {
+ AllowPartialResults *bool // If true, allows partial results to be returned if some shards are down.
+ BatchSize *int32 // Specifies the number of documents to return in every batch.
+ Collation *Collation // Specifies a collation to be used
+ Comment *string // Specifies a string to help trace the operation through the database.
+ CursorType *CursorType // Specifies the type of cursor to use
+ Hint interface{} // Specifies the index to use.
+ Max interface{} // Sets an exclusive upper bound for a specific index
+ MaxAwaitTime *time.Duration // Specifies the maximum amount of time for the server to wait on new documents.
+ MaxTime *time.Duration // Specifies the maximum amount of time to allow the query to run.
+ Min interface{} // Specifies the inclusive lower bound for a specific index.
+ NoCursorTimeout *bool // If true, prevents cursors from timing out after an inactivity period.
+ OplogReplay *bool // Adds an option for internal use only and should not be set.
+ Projection interface{} // Limits the fields returned for all documents.
+ ReturnKey *bool // If true, only returns index keys for all result documents.
+ ShowRecordID *bool // If true, a $recordId field with the record identifier will be added to the returned documents.
+ Skip *int64 // Specifies the number of documents to skip before returning
+ Snapshot *bool // If true, prevents the cursor from returning a document more than once because of an intervening write operation.
+ Sort interface{} // Specifies the order in which to return results.
+}
+
+// FindOne creates a new FindOneOptions instance.
+func FindOne() *FindOneOptions {
+ return &FindOneOptions{}
+}
+
+// SetAllowPartialResults sets whether partial results can be returned if some shards are down.
+func (f *FindOneOptions) SetAllowPartialResults(b bool) *FindOneOptions {
+ f.AllowPartialResults = &b
+ return f
+}
+
+// SetBatchSize sets the number of documents to return in each batch.
+func (f *FindOneOptions) SetBatchSize(i int32) *FindOneOptions {
+ f.BatchSize = &i
+ return f
+}
+
+// SetCollation specifies a Collation to use for the Find operation.
+func (f *FindOneOptions) SetCollation(collation *Collation) *FindOneOptions {
+ f.Collation = collation
+ return f
+}
+
+// SetComment specifies a string to help trace the operation through the database.
+func (f *FindOneOptions) SetComment(comment string) *FindOneOptions {
+ f.Comment = &comment
+ return f
+}
+
+// SetCursorType specifes the type of cursor to use.
+func (f *FindOneOptions) SetCursorType(ct CursorType) *FindOneOptions {
+ f.CursorType = &ct
+ return f
+}
+
+// SetHint specifies the index to use.
+func (f *FindOneOptions) SetHint(hint interface{}) *FindOneOptions {
+ f.Hint = hint
+ return f
+}
+
+// SetMax specifies an exclusive upper bound for a specific index.
+func (f *FindOneOptions) SetMax(max interface{}) *FindOneOptions {
+ f.Max = max
+ return f
+}
+
+// SetMaxAwaitTime specifies the max amount of time for the server to wait on new documents.
+// For server versions < 3.2, this option is ignored.
+func (f *FindOneOptions) SetMaxAwaitTime(d time.Duration) *FindOneOptions {
+ f.MaxAwaitTime = &d
+ return f
+}
+
+// SetMaxTime specifies the max time to allow the query to run.
+func (f *FindOneOptions) SetMaxTime(d time.Duration) *FindOneOptions {
+ f.MaxTime = &d
+ return f
+}
+
+// SetMin specifies the inclusive lower bound for a specific index.
+func (f *FindOneOptions) SetMin(min interface{}) *FindOneOptions {
+ f.Min = min
+ return f
+}
+
+// SetNoCursorTimeout specifies whether or not cursors should time out after a period of inactivity.
+func (f *FindOneOptions) SetNoCursorTimeout(b bool) *FindOneOptions {
+ f.NoCursorTimeout = &b
+ return f
+}
+
+// SetOplogReplay adds an option for internal use only and should not be set.
+func (f *FindOneOptions) SetOplogReplay(b bool) *FindOneOptions {
+ f.OplogReplay = &b
+ return f
+}
+
+// SetProjection adds an option to limit the fields returned for all documents.
+func (f *FindOneOptions) SetProjection(projection interface{}) *FindOneOptions {
+ f.Projection = projection
+ return f
+}
+
+// SetReturnKey adds an option to only return index keys for all result documents.
+func (f *FindOneOptions) SetReturnKey(b bool) *FindOneOptions {
+ f.ReturnKey = &b
+ return f
+}
+
+// SetShowRecordID adds an option to determine whether to return the record identifier for each document.
+// If true, a $recordId field will be added to each returned document.
+func (f *FindOneOptions) SetShowRecordID(b bool) *FindOneOptions {
+ f.ShowRecordID = &b
+ return f
+}
+
+// SetSkip specifies the number of documents to skip before returning.
+func (f *FindOneOptions) SetSkip(i int64) *FindOneOptions {
+ f.Skip = &i
+ return f
+}
+
+// SetSnapshot prevents the cursor from returning a document more than once because of an intervening write operation.
+func (f *FindOneOptions) SetSnapshot(b bool) *FindOneOptions {
+ f.Snapshot = &b
+ return f
+}
+
+// SetSort specifies the order in which to return documents.
+func (f *FindOneOptions) SetSort(sort interface{}) *FindOneOptions {
+ f.Sort = sort
+ return f
+}
+
+// MergeFindOneOptions combines the argued FindOneOptions into a single FindOneOptions in a last-one-wins fashion
+func MergeFindOneOptions(opts ...*FindOneOptions) *FindOneOptions {
+ fo := FindOne()
+ for _, opt := range opts {
+ if opt == nil {
+ continue
+ }
+ if opt.AllowPartialResults != nil {
+ fo.AllowPartialResults = opt.AllowPartialResults
+ }
+ if opt.BatchSize != nil {
+ fo.BatchSize = opt.BatchSize
+ }
+ if opt.Collation != nil {
+ fo.Collation = opt.Collation
+ }
+ if opt.Comment != nil {
+ fo.Comment = opt.Comment
+ }
+ if opt.CursorType != nil {
+ fo.CursorType = opt.CursorType
+ }
+ if opt.Hint != nil {
+ fo.Hint = opt.Hint
+ }
+ if opt.Max != nil {
+ fo.Max = opt.Max
+ }
+ if opt.MaxAwaitTime != nil {
+ fo.MaxAwaitTime = opt.MaxAwaitTime
+ }
+ if opt.MaxTime != nil {
+ fo.MaxTime = opt.MaxTime
+ }
+ if opt.Min != nil {
+ fo.Min = opt.Min
+ }
+ if opt.NoCursorTimeout != nil {
+ fo.NoCursorTimeout = opt.NoCursorTimeout
+ }
+ if opt.OplogReplay != nil {
+ fo.OplogReplay = opt.OplogReplay
+ }
+ if opt.Projection != nil {
+ fo.Projection = opt.Projection
+ }
+ if opt.ReturnKey != nil {
+ fo.ReturnKey = opt.ReturnKey
+ }
+ if opt.ShowRecordID != nil {
+ fo.ShowRecordID = opt.ShowRecordID
+ }
+ if opt.Skip != nil {
+ fo.Skip = opt.Skip
+ }
+ if opt.Snapshot != nil {
+ fo.Snapshot = opt.Snapshot
+ }
+ if opt.Sort != nil {
+ fo.Sort = opt.Sort
+ }
+ }
+
+ return fo
+}
+
+// FindOneAndReplaceOptions represent all possible options to the findOne() function.
+type FindOneAndReplaceOptions struct {
+ BypassDocumentValidation *bool // If true, allows the write to opt out of document-level validation.
+ Collation *Collation // Specifies a collation to be used
+ MaxTime *time.Duration // Specifies the maximum amount of time to allow the query to run.
+ Projection interface{} // Limits the fields returned for all documents.
+ ReturnDocument *ReturnDocument // Specifies whether the original or updated document should be returned.
+ Sort interface{} // Specifies the order in which to return results.
+ Upsert *bool // If true, creates a a new document if no document matches the query.
+}
+
+// FindOneAndReplace creates a new FindOneAndReplaceOptions instance.
+func FindOneAndReplace() *FindOneAndReplaceOptions {
+ return &FindOneAndReplaceOptions{}
+}
+
+// SetBypassDocumentValidation specifies whether or not the write should opt out of document-level validation.
+// Valid for server versions >= 3.2. For servers < 3.2, this option is ignored.
+func (f *FindOneAndReplaceOptions) SetBypassDocumentValidation(b bool) *FindOneAndReplaceOptions {
+ f.BypassDocumentValidation = &b
+ return f
+}
+
+// SetCollation specifies a Collation to use for the Find operation.
+func (f *FindOneAndReplaceOptions) SetCollation(collation *Collation) *FindOneAndReplaceOptions {
+ f.Collation = collation
+ return f
+}
+
+// SetMaxTime specifies the max time to allow the query to run.
+func (f *FindOneAndReplaceOptions) SetMaxTime(d time.Duration) *FindOneAndReplaceOptions {
+ f.MaxTime = &d
+ return f
+}
+
+// SetProjection adds an option to limit the fields returned for all documents.
+func (f *FindOneAndReplaceOptions) SetProjection(projection interface{}) *FindOneAndReplaceOptions {
+ f.Projection = projection
+ return f
+}
+
+// SetReturnDocument specifies whether the original or updated document should be returned.
+// If set to Before, the original document will be returned. If set to After, the updated document
+// will be returned.
+func (f *FindOneAndReplaceOptions) SetReturnDocument(rd ReturnDocument) *FindOneAndReplaceOptions {
+ f.ReturnDocument = &rd
+ return f
+}
+
+// SetSort specifies the order in which to return documents.
+func (f *FindOneAndReplaceOptions) SetSort(sort interface{}) *FindOneAndReplaceOptions {
+ f.Sort = sort
+ return f
+}
+
+// SetUpsert specifies if a new document should be created if no document matches the query.
+func (f *FindOneAndReplaceOptions) SetUpsert(b bool) *FindOneAndReplaceOptions {
+ f.Upsert = &b
+ return f
+}
+
+// MergeFindOneAndReplaceOptions combines the argued FindOneAndReplaceOptions into a single FindOneAndReplaceOptions in a last-one-wins fashion
+func MergeFindOneAndReplaceOptions(opts ...*FindOneAndReplaceOptions) *FindOneAndReplaceOptions {
+ fo := FindOneAndReplace()
+ for _, opt := range opts {
+ if opt == nil {
+ continue
+ }
+ if opt.BypassDocumentValidation != nil {
+ fo.BypassDocumentValidation = opt.BypassDocumentValidation
+ }
+ if opt.Collation != nil {
+ fo.Collation = opt.Collation
+ }
+ if opt.MaxTime != nil {
+ fo.MaxTime = opt.MaxTime
+ }
+ if opt.Projection != nil {
+ fo.Projection = opt.Projection
+ }
+ if opt.ReturnDocument != nil {
+ fo.ReturnDocument = opt.ReturnDocument
+ }
+ if opt.Sort != nil {
+ fo.Sort = opt.Sort
+ }
+ if opt.Upsert != nil {
+ fo.Upsert = opt.Upsert
+ }
+ }
+
+ return fo
+}
+
+// FindOneAndUpdateOptions represent all possible options to the findOne() function.
+type FindOneAndUpdateOptions struct {
+ ArrayFilters *ArrayFilters // A set of filters specifying to which array elements an update should apply.
+ BypassDocumentValidation *bool // If true, allows the write to opt out of document-level validation.
+ Collation *Collation // Specifies a collation to be used
+ MaxTime *time.Duration // Specifies the maximum amount of time to allow the query to run.
+ Projection interface{} // Limits the fields returned for all documents.
+ ReturnDocument *ReturnDocument // Specifies whether the original or updated document should be returned.
+ Sort interface{} // Specifies the order in which to return results.
+ Upsert *bool // If true, creates a a new document if no document matches the query.
+}
+
+// FindOneAndUpdate creates a new FindOneAndUpdateOptions instance.
+func FindOneAndUpdate() *FindOneAndUpdateOptions {
+ return &FindOneAndUpdateOptions{}
+}
+
+// SetBypassDocumentValidation sets filters that specify to which array elements an update should apply.
+func (f *FindOneAndUpdateOptions) SetBypassDocumentValidation(b bool) *FindOneAndUpdateOptions {
+ f.BypassDocumentValidation = &b
+ return f
+}
+
+// SetArrayFilters specifies a set of filters, which
+func (f *FindOneAndUpdateOptions) SetArrayFilters(filters ArrayFilters) *FindOneAndUpdateOptions {
+ f.ArrayFilters = &filters
+ return f
+}
+
+// SetCollation specifies a Collation to use for the Find operation.
+func (f *FindOneAndUpdateOptions) SetCollation(collation *Collation) *FindOneAndUpdateOptions {
+ f.Collation = collation
+ return f
+}
+
+// SetMaxTime specifies the max time to allow the query to run.
+func (f *FindOneAndUpdateOptions) SetMaxTime(d time.Duration) *FindOneAndUpdateOptions {
+ f.MaxTime = &d
+ return f
+}
+
+// SetProjection adds an option to limit the fields returned for all documents.
+func (f *FindOneAndUpdateOptions) SetProjection(projection interface{}) *FindOneAndUpdateOptions {
+ f.Projection = projection
+ return f
+}
+
+// SetReturnDocument specifies whether the original or updated document should be returned.
+// If set to Before, the original document will be returned. If set to After, the updated document
+// will be returned.
+func (f *FindOneAndUpdateOptions) SetReturnDocument(rd ReturnDocument) *FindOneAndUpdateOptions {
+ f.ReturnDocument = &rd
+ return f
+}
+
+// SetSort specifies the order in which to return documents.
+func (f *FindOneAndUpdateOptions) SetSort(sort interface{}) *FindOneAndUpdateOptions {
+ f.Sort = sort
+ return f
+}
+
+// SetUpsert specifies if a new document should be created if no document matches the query.
+func (f *FindOneAndUpdateOptions) SetUpsert(b bool) *FindOneAndUpdateOptions {
+ f.Upsert = &b
+ return f
+}
+
+// MergeFindOneAndUpdateOptions combines the argued FindOneAndUpdateOptions into a single FindOneAndUpdateOptions in a last-one-wins fashion
+func MergeFindOneAndUpdateOptions(opts ...*FindOneAndUpdateOptions) *FindOneAndUpdateOptions {
+ fo := FindOneAndUpdate()
+ for _, opt := range opts {
+ if opt == nil {
+ continue
+ }
+ if opt.ArrayFilters != nil {
+ fo.ArrayFilters = opt.ArrayFilters
+ }
+ if opt.BypassDocumentValidation != nil {
+ fo.BypassDocumentValidation = opt.BypassDocumentValidation
+ }
+ if opt.Collation != nil {
+ fo.Collation = opt.Collation
+ }
+ if opt.MaxTime != nil {
+ fo.MaxTime = opt.MaxTime
+ }
+ if opt.Projection != nil {
+ fo.Projection = opt.Projection
+ }
+ if opt.ReturnDocument != nil {
+ fo.ReturnDocument = opt.ReturnDocument
+ }
+ if opt.Sort != nil {
+ fo.Sort = opt.Sort
+ }
+ if opt.Upsert != nil {
+ fo.Upsert = opt.Upsert
+ }
+ }
+
+ return fo
+}
+
+// FindOneAndDeleteOptions represent all possible options to the findOne() function.
+type FindOneAndDeleteOptions struct {
+ Collation *Collation // Specifies a collation to be used
+ MaxTime *time.Duration // Specifies the maximum amount of time to allow the query to run.
+ Projection interface{} // Limits the fields returned for all documents.
+ Sort interface{} // Specifies the order in which to return results.
+}
+
+// FindOneAndDelete creates a new FindOneAndDeleteOptions instance.
+func FindOneAndDelete() *FindOneAndDeleteOptions {
+ return &FindOneAndDeleteOptions{}
+}
+
+// SetCollation specifies a Collation to use for the Find operation.
+// Valid for server versions >= 3.4
+func (f *FindOneAndDeleteOptions) SetCollation(collation *Collation) *FindOneAndDeleteOptions {
+ f.Collation = collation
+ return f
+}
+
+// SetMaxTime specifies the max time to allow the query to run.
+func (f *FindOneAndDeleteOptions) SetMaxTime(d time.Duration) *FindOneAndDeleteOptions {
+ f.MaxTime = &d
+ return f
+}
+
+// SetProjection adds an option to limit the fields returned for all documents.
+func (f *FindOneAndDeleteOptions) SetProjection(projection interface{}) *FindOneAndDeleteOptions {
+ f.Projection = projection
+ return f
+}
+
+// SetSort specifies the order in which to return documents.
+func (f *FindOneAndDeleteOptions) SetSort(sort interface{}) *FindOneAndDeleteOptions {
+ f.Sort = sort
+ return f
+}
+
+// MergeFindOneAndDeleteOptions combines the argued FindOneAndDeleteOptions into a single FindOneAndDeleteOptions in a last-one-wins fashion
+func MergeFindOneAndDeleteOptions(opts ...*FindOneAndDeleteOptions) *FindOneAndDeleteOptions {
+ fo := FindOneAndDelete()
+ for _, opt := range opts {
+ if opt == nil {
+ continue
+ }
+ if opt.Collation != nil {
+ fo.Collation = opt.Collation
+ }
+ if opt.MaxTime != nil {
+ fo.MaxTime = opt.MaxTime
+ }
+ if opt.Projection != nil {
+ fo.Projection = opt.Projection
+ }
+ if opt.Sort != nil {
+ fo.Sort = opt.Sort
+ }
+ }
+
+ return fo
+}
diff --git a/vendor/github.com/mongodb/mongo-go-driver/mongo/options/gridfsoptions.go b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/gridfsoptions.go
new file mode 100644
index 0000000..232a1c8
--- /dev/null
+++ b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/gridfsoptions.go
@@ -0,0 +1,268 @@
+// Copyright (C) MongoDB, Inc. 2017-present.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+
+package options
+
+import (
+ "time"
+
+ "github.com/mongodb/mongo-go-driver/mongo/readconcern"
+ "github.com/mongodb/mongo-go-driver/mongo/readpref"
+ "github.com/mongodb/mongo-go-driver/mongo/writeconcern"
+ "github.com/mongodb/mongo-go-driver/x/bsonx"
+)
+
+// DefaultName is the default name for a GridFS bucket.
+var DefaultName = "fs"
+
+// DefaultChunkSize is the default size of each file chunk in bytes.
+var DefaultChunkSize int32 = 255 * 1000
+
+// DefaultRevision is the default revision number for a download by name operation.
+var DefaultRevision int32 = -1
+
+// BucketOptions represents all possible options to configure a GridFS bucket.
+type BucketOptions struct {
+ Name *string // The bucket name. Defaults to "fs".
+ ChunkSizeBytes *int32 // The chunk size in bytes. Defaults to 255KB.
+ WriteConcern *writeconcern.WriteConcern // The write concern for the bucket. Defaults to the write concern of the database.
+ ReadConcern *readconcern.ReadConcern // The read concern for the bucket. Defaults to the read concern of the database.
+ ReadPreference *readpref.ReadPref // The read preference for the bucket. Defaults to the read preference of the database.
+}
+
+// GridFSBucket creates a new *BucketOptions
+func GridFSBucket() *BucketOptions {
+ return &BucketOptions{
+ Name: &DefaultName,
+ ChunkSizeBytes: &DefaultChunkSize,
+ }
+}
+
+// SetName sets the name for the bucket. Defaults to "fs" if not set.
+func (b *BucketOptions) SetName(name string) *BucketOptions {
+ b.Name = &name
+ return b
+}
+
+// SetChunkSizeBytes sets the chunk size in bytes for the bucket. Defaults to 255KB if not set.
+func (b *BucketOptions) SetChunkSizeBytes(i int32) *BucketOptions {
+ b.ChunkSizeBytes = &i
+ return b
+}
+
+// SetWriteConcern sets the write concern for the bucket.
+func (b *BucketOptions) SetWriteConcern(wc *writeconcern.WriteConcern) *BucketOptions {
+ b.WriteConcern = wc
+ return b
+}
+
+// SetReadConcern sets the read concern for the bucket.
+func (b *BucketOptions) SetReadConcern(rc *readconcern.ReadConcern) *BucketOptions {
+ b.ReadConcern = rc
+ return b
+}
+
+// SetReadPreference sets the read preference for the bucket.
+func (b *BucketOptions) SetReadPreference(rp *readpref.ReadPref) *BucketOptions {
+ b.ReadPreference = rp
+ return b
+}
+
+// MergeBucketOptions combines the given *BucketOptions into a single *BucketOptions.
+// If the name or chunk size is not set in any of the given *BucketOptions, the resulting *BucketOptions will have
+// name "fs" and chunk size 255KB.
+func MergeBucketOptions(opts ...*BucketOptions) *BucketOptions {
+ b := GridFSBucket()
+
+ for _, opt := range opts {
+ if opt == nil {
+ continue
+ }
+ if opt.Name != nil {
+ b.Name = opt.Name
+ }
+ if opt.ChunkSizeBytes != nil {
+ b.ChunkSizeBytes = opt.ChunkSizeBytes
+ }
+ if opt.WriteConcern != nil {
+ b.WriteConcern = opt.WriteConcern
+ }
+ if opt.ReadConcern != nil {
+ b.ReadConcern = opt.ReadConcern
+ }
+ if opt.ReadPreference != nil {
+ b.ReadPreference = opt.ReadPreference
+ }
+ }
+
+ return b
+}
+
+// UploadOptions represents all possible options for a GridFS upload operation.
+type UploadOptions struct {
+ ChunkSizeBytes *int32 // Chunk size in bytes. Defaults to the chunk size of the bucket.
+ Metadata bsonx.Doc // User data for the 'metadata' field of the files collection document.
+}
+
+// GridFSUpload creates a new *UploadOptions
+func GridFSUpload() *UploadOptions {
+ return &UploadOptions{}
+}
+
+// SetChunkSizeBytes sets the chunk size in bytes for the upload. Defaults to 255KB if not set.
+func (u *UploadOptions) SetChunkSizeBytes(i int32) *UploadOptions {
+ u.ChunkSizeBytes = &i
+ return u
+}
+
+// SetMetadata specfies the metadata for the upload.
+func (u *UploadOptions) SetMetadata(doc bsonx.Doc) *UploadOptions {
+ u.Metadata = doc
+ return u
+}
+
+// MergeUploadOptions combines the given *UploadOptions into a single *UploadOptions.
+// If the chunk size is not set in any of the given *UploadOptions, the resulting *UploadOptions will have chunk size
+// 255KB.
+func MergeUploadOptions(opts ...*UploadOptions) *UploadOptions {
+ u := GridFSUpload()
+
+ for _, opt := range opts {
+ if opt == nil {
+ continue
+ }
+ if opt.ChunkSizeBytes != nil {
+ u.ChunkSizeBytes = opt.ChunkSizeBytes
+ }
+ if opt.Metadata != nil {
+ u.Metadata = opt.Metadata
+ }
+ }
+
+ return u
+}
+
+// NameOptions represents all options that can be used for a GridFS download by name operation.
+type NameOptions struct {
+ Revision *int32 // Which revision (documents with the same filename and different uploadDate). Defaults to -1 (the most recent revision).
+}
+
+// GridFSName creates a new *NameOptions
+func GridFSName() *NameOptions {
+ return &NameOptions{}
+}
+
+// SetRevision specifies which revision of the file to retrieve. Defaults to -1.
+// * Revision numbers are defined as follows:
+// * 0 = the original stored file
+// * 1 = the first revision
+// * 2 = the second revision
+// * etc…
+// * -2 = the second most recent revision
+// * -1 = the most recent revision
+func (n *NameOptions) SetRevision(r int32) *NameOptions {
+ n.Revision = &r
+ return n
+}
+
+// MergeNameOptions combines the given *NameOptions into a single *NameOptions in a last one wins fashion.
+func MergeNameOptions(opts ...*NameOptions) *NameOptions {
+ n := GridFSName()
+ n.Revision = &DefaultRevision
+
+ for _, opt := range opts {
+ if opt == nil {
+ continue
+ }
+ if opt.Revision != nil {
+ n.Revision = opt.Revision
+ }
+ }
+
+ return n
+}
+
+// GridFSFindOptions represents all options for a GridFS find operation.
+type GridFSFindOptions struct {
+ BatchSize *int32
+ Limit *int32
+ MaxTime *time.Duration
+ NoCursorTimeout *bool
+ Skip *int32
+ Sort interface{}
+}
+
+// GridFSFind creates a new GridFSFindOptions instance.
+func GridFSFind() *GridFSFindOptions {
+ return &GridFSFindOptions{}
+}
+
+// SetBatchSize sets the number of documents to return in each batch.
+func (f *GridFSFindOptions) SetBatchSize(i int32) *GridFSFindOptions {
+ f.BatchSize = &i
+ return f
+}
+
+// SetLimit specifies a limit on the number of results.
+// A negative limit implies that only 1 batch should be returned.
+func (f *GridFSFindOptions) SetLimit(i int32) *GridFSFindOptions {
+ f.Limit = &i
+ return f
+}
+
+// SetMaxTime specifies the max time to allow the query to run.
+func (f *GridFSFindOptions) SetMaxTime(d time.Duration) *GridFSFindOptions {
+ f.MaxTime = &d
+ return f
+}
+
+// SetNoCursorTimeout specifies whether or not cursors should time out after a period of inactivity.
+func (f *GridFSFindOptions) SetNoCursorTimeout(b bool) *GridFSFindOptions {
+ f.NoCursorTimeout = &b
+ return f
+}
+
+// SetSkip specifies the number of documents to skip before returning.
+func (f *GridFSFindOptions) SetSkip(i int32) *GridFSFindOptions {
+ f.Skip = &i
+ return f
+}
+
+// SetSort specifies the order in which to return documents.
+func (f *GridFSFindOptions) SetSort(sort interface{}) *GridFSFindOptions {
+ f.Sort = sort
+ return f
+}
+
+// MergeGridFSFindOptions combines the argued GridFSFindOptions into a single GridFSFindOptions in a last-one-wins fashion
+func MergeGridFSFindOptions(opts ...*GridFSFindOptions) *GridFSFindOptions {
+ fo := GridFSFind()
+ for _, opt := range opts {
+ if opt == nil {
+ continue
+ }
+ if opt.BatchSize != nil {
+ fo.BatchSize = opt.BatchSize
+ }
+ if opt.Limit != nil {
+ fo.Limit = opt.Limit
+ }
+ if opt.MaxTime != nil {
+ fo.MaxTime = opt.MaxTime
+ }
+ if opt.NoCursorTimeout != nil {
+ fo.NoCursorTimeout = opt.NoCursorTimeout
+ }
+ if opt.Skip != nil {
+ fo.Skip = opt.Skip
+ }
+ if opt.Sort != nil {
+ fo.Sort = opt.Sort
+ }
+ }
+
+ return fo
+}
diff --git a/vendor/github.com/mongodb/mongo-go-driver/mongo/options/indexoptions.go b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/indexoptions.go
new file mode 100644
index 0000000..2fda698
--- /dev/null
+++ b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/indexoptions.go
@@ -0,0 +1,326 @@
+// Copyright (C) MongoDB, Inc. 2017-present.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+
+package options
+
+import (
+ "time"
+)
+
+// CreateIndexesOptions represents all possible options for the create() function.
+type CreateIndexesOptions struct {
+ MaxTime *time.Duration // The maximum amount of time to allow the query to run.
+}
+
+// CreateIndexes creates a new CreateIndexesOptions instance.
+func CreateIndexes() *CreateIndexesOptions {
+ return &CreateIndexesOptions{}
+}
+
+// SetMaxTime specifies the maximum amount of time to allow the query to run.
+func (c *CreateIndexesOptions) SetMaxTime(d time.Duration) *CreateIndexesOptions {
+ c.MaxTime = &d
+ return c
+}
+
+// MergeCreateIndexesOptions combines the given *CreateIndexesOptions into a single *CreateIndexesOptions in a last one
+// wins fashion.
+func MergeCreateIndexesOptions(opts ...*CreateIndexesOptions) *CreateIndexesOptions {
+ c := CreateIndexes()
+ for _, opt := range opts {
+ if opt == nil {
+ continue
+ }
+ if opt.MaxTime != nil {
+ c.MaxTime = opt.MaxTime
+ }
+ }
+
+ return c
+}
+
+// DropIndexesOptions represents all possible options for the create() function.
+type DropIndexesOptions struct {
+ MaxTime *time.Duration
+}
+
+// DropIndexes creates a new DropIndexesOptions instance.
+func DropIndexes() *DropIndexesOptions {
+ return &DropIndexesOptions{}
+}
+
+// SetMaxTime specifies the maximum amount of time to allow the query to run.
+func (d *DropIndexesOptions) SetMaxTime(duration time.Duration) *DropIndexesOptions {
+ d.MaxTime = &duration
+ return d
+}
+
+// MergeDropIndexesOptions combines the given *DropIndexesOptions into a single *DropIndexesOptions in a last one
+// wins fashion.
+func MergeDropIndexesOptions(opts ...*DropIndexesOptions) *DropIndexesOptions {
+ c := DropIndexes()
+ for _, opt := range opts {
+ if opt == nil {
+ continue
+ }
+ if opt.MaxTime != nil {
+ c.MaxTime = opt.MaxTime
+ }
+ }
+
+ return c
+}
+
+// ListIndexesOptions represents all possible options for the create() function.
+type ListIndexesOptions struct {
+ BatchSize *int32
+ MaxTime *time.Duration
+}
+
+// ListIndexes creates a new ListIndexesOptions instance.
+func ListIndexes() *ListIndexesOptions {
+ return &ListIndexesOptions{}
+}
+
+// SetBatchSize specifies the number of documents to return in every batch.
+func (l *ListIndexesOptions) SetBatchSize(i int32) *ListIndexesOptions {
+ l.BatchSize = &i
+ return l
+}
+
+// SetMaxTime specifies the maximum amount of time to allow the query to run.
+func (l *ListIndexesOptions) SetMaxTime(d time.Duration) *ListIndexesOptions {
+ l.MaxTime = &d
+ return l
+}
+
+// MergeListIndexesOptions combines the given *ListIndexesOptions into a single *ListIndexesOptions in a last one
+// wins fashion.
+func MergeListIndexesOptions(opts ...*ListIndexesOptions) *ListIndexesOptions {
+ c := ListIndexes()
+ for _, opt := range opts {
+ if opt == nil {
+ continue
+ }
+ if opt.MaxTime != nil {
+ c.MaxTime = opt.MaxTime
+ }
+ }
+
+ return c
+}
+
+// IndexOptions represents all possible options to configure a new index.
+type IndexOptions struct {
+ Background *bool
+ ExpireAfterSeconds *int32
+ Name *string
+ Sparse *bool
+ StorageEngine interface{}
+ Unique *bool
+ Version *int32
+ DefaultLanguage *string
+ LanguageOverride *string
+ TextVersion *int32
+ Weights interface{}
+ SphereVersion *int32
+ Bits *int32
+ Max *float64
+ Min *float64
+ BucketSize *int32
+ PartialFilterExpression interface{}
+ Collation *Collation
+}
+
+// Index creates a new *IndexOptions
+func Index() *IndexOptions {
+ return &IndexOptions{}
+}
+
+// SetBackground sets the background option. If true, the server will create the index in the background and not block
+// other tasks
+func (i *IndexOptions) SetBackground(background bool) *IndexOptions {
+ i.Background = &background
+ return i
+}
+
+// SetExpireAfterSeconds specifies the number of seconds for a document to remain in a collection.
+func (i *IndexOptions) SetExpireAfterSeconds(seconds int32) *IndexOptions {
+ i.ExpireAfterSeconds = &seconds
+ return i
+}
+
+// SetName specifies a name for the index.
+// If not set, a name will be generated in the format "[field]_[direction]".
+// If multiple indexes are created for the same key pattern with different collations, a name must be provided to avoid
+// ambiguity.
+func (i *IndexOptions) SetName(name string) *IndexOptions {
+ i.Name = &name
+ return i
+}
+
+// SetSparse sets the sparse option.
+// If true, the index will only reference documents with the specified field in the index.
+func (i *IndexOptions) SetSparse(sparse bool) *IndexOptions {
+ i.Sparse = &sparse
+ return i
+}
+
+// SetStorageEngine specifies the storage engine to use.
+// Valid for server versions >= 3.0
+func (i *IndexOptions) SetStorageEngine(engine interface{}) *IndexOptions {
+ i.StorageEngine = engine
+ return i
+}
+
+// SetUnique forces the index to be unique.
+func (i *IndexOptions) SetUnique(unique bool) *IndexOptions {
+ i.Unique = &unique
+ return i
+}
+
+// SetVersion specifies the index version number, either 0 or 1.
+func (i *IndexOptions) SetVersion(version int32) *IndexOptions {
+ i.Version = &version
+ return i
+}
+
+// SetDefaultLanguage specifies the default language for text indexes.
+// If not set, this will default to english.
+func (i *IndexOptions) SetDefaultLanguage(language string) *IndexOptions {
+ i.DefaultLanguage = &language
+ return i
+}
+
+// SetLanguageOverride specifies the field in the document to override the language.
+func (i *IndexOptions) SetLanguageOverride(override string) *IndexOptions {
+ i.LanguageOverride = &override
+ return i
+}
+
+// SetTextVersion specifies the text index version number.
+// MongoDB version 2.4 can only support version 1.
+// MongoDB versions 2.6 and higher can support versions 1 or 2.
+func (i *IndexOptions) SetTextVersion(version int32) *IndexOptions {
+ i.TextVersion = &version
+ return i
+}
+
+// SetWeights specifies fields in the index and their corresponding weight values.
+func (i *IndexOptions) SetWeights(weights interface{}) *IndexOptions {
+ i.Weights = weights
+ return i
+}
+
+// SetSphereVersion specifies the 2dsphere index version number.
+// MongoDB version 2.4 can only support version 1.
+// MongoDB versions 2.6 and higher can support versions 1 or 2.
+func (i *IndexOptions) SetSphereVersion(version int32) *IndexOptions {
+ i.SphereVersion = &version
+ return i
+}
+
+// SetBits specifies the precision of the stored geo hash in the 2d index, from 1 to 32.
+func (i *IndexOptions) SetBits(bits int32) *IndexOptions {
+ i.Bits = &bits
+ return i
+}
+
+// SetMax specifies the maximum boundary for latitude and longitude in the 2d index.
+func (i *IndexOptions) SetMax(max float64) *IndexOptions {
+ i.Max = &max
+ return i
+}
+
+// SetMin specifies the minimum boundary for latitude and longitude in the 2d index.
+func (i *IndexOptions) SetMin(min float64) *IndexOptions {
+ i.Min = &min
+ return i
+}
+
+// SetBucketSize specifies number of units within which to group the location values in a geo haystack index.
+func (i *IndexOptions) SetBucketSize(bucketSize int32) *IndexOptions {
+ i.BucketSize = &bucketSize
+ return i
+}
+
+// SetPartialFilterExpression specifies a filter for use in a partial index. Only documents that match the filter
+// expression are included in the index.
+func (i *IndexOptions) SetPartialFilterExpression(expression interface{}) *IndexOptions {
+ i.PartialFilterExpression = expression
+ return i
+}
+
+// SetCollation specifies a Collation to use for the operation.
+// Valid for server versions >= 3.4
+func (i *IndexOptions) SetCollation(collation *Collation) *IndexOptions {
+ i.Collation = collation
+ return i
+}
+
+// MergeIndexOptions combines the given *IndexOptions into a single *IndexOptions in a last one wins fashion.
+func MergeIndexOptions(opts ...*IndexOptions) *IndexOptions {
+ i := Index()
+
+ for _, opt := range opts {
+ if opt.Background != nil {
+ i.Background = opt.Background
+ }
+ if opt.ExpireAfterSeconds != nil {
+ i.ExpireAfterSeconds = opt.ExpireAfterSeconds
+ }
+ if opt.Name != nil {
+ i.Name = opt.Name
+ }
+ if opt.Sparse != nil {
+ i.Sparse = opt.Sparse
+ }
+ if opt.StorageEngine != nil {
+ i.StorageEngine = opt.StorageEngine
+ }
+ if opt.Unique != nil {
+ i.Unique = opt.Unique
+ }
+ if opt.Version != nil {
+ i.Version = opt.Version
+ }
+ if opt.DefaultLanguage != nil {
+ i.DefaultLanguage = opt.DefaultLanguage
+ }
+ if opt.LanguageOverride != nil {
+ i.LanguageOverride = opt.LanguageOverride
+ }
+ if opt.TextVersion != nil {
+ i.TextVersion = opt.TextVersion
+ }
+ if opt.Weights != nil {
+ i.Weights = opt.Weights
+ }
+ if opt.SphereVersion != nil {
+ i.SphereVersion = opt.SphereVersion
+ }
+ if opt.Bits != nil {
+ i.Bits = opt.Bits
+ }
+ if opt.Max != nil {
+ i.Max = opt.Max
+ }
+ if opt.Min != nil {
+ i.Min = opt.Min
+ }
+ if opt.BucketSize != nil {
+ i.BucketSize = opt.BucketSize
+ }
+ if opt.PartialFilterExpression != nil {
+ i.PartialFilterExpression = opt.PartialFilterExpression
+ }
+ if opt.Collation != nil {
+ i.Collation = opt.Collation
+ }
+ }
+
+ return i
+}
diff --git a/vendor/github.com/mongodb/mongo-go-driver/mongo/options/insertoptions.go b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/insertoptions.go
new file mode 100644
index 0000000..064ede3
--- /dev/null
+++ b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/insertoptions.go
@@ -0,0 +1,84 @@
+// Copyright (C) MongoDB, Inc. 2017-present.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+
+package options
+
+// InsertOneOptions represents all possible options to the insertOne()
+type InsertOneOptions struct {
+ BypassDocumentValidation *bool // If true, allows the write to opt-out of document level validation
+}
+
+// InsertOne returns a pointer to a new InsertOneOptions
+func InsertOne() *InsertOneOptions {
+ return &InsertOneOptions{}
+}
+
+// SetBypassDocumentValidation allows the write to opt-out of document level validation.
+// Valid for server versions >= 3.2. For servers < 3.2, this option is ignored.
+func (ioo *InsertOneOptions) SetBypassDocumentValidation(b bool) *InsertOneOptions {
+ ioo.BypassDocumentValidation = &b
+ return ioo
+}
+
+// MergeInsertOneOptions combines the argued InsertOneOptions into a single InsertOneOptions in a last-one-wins fashion
+func MergeInsertOneOptions(opts ...*InsertOneOptions) *InsertOneOptions {
+ ioOpts := InsertOne()
+ for _, ioo := range opts {
+ if ioo == nil {
+ continue
+ }
+ if ioo.BypassDocumentValidation != nil {
+ ioOpts.BypassDocumentValidation = ioo.BypassDocumentValidation
+ }
+ }
+
+ return ioOpts
+}
+
+// InsertManyOptions represents all possible options to the insertMany()
+type InsertManyOptions struct {
+ BypassDocumentValidation *bool // If true, allows the write to opt-out of document level validation
+ Ordered *bool // If true, when an insert fails, return without performing the remaining inserts. Defaults to true.
+}
+
+// InsertMany returns a pointer to a new InsertManyOptions
+func InsertMany() *InsertManyOptions {
+ return &InsertManyOptions{
+ Ordered: &DefaultOrdered,
+ }
+}
+
+// SetBypassDocumentValidation allows the write to opt-out of document level validation.
+// Valid for server versions >= 3.2. For servers < 3.2, this option is ignored.
+func (imo *InsertManyOptions) SetBypassDocumentValidation(b bool) *InsertManyOptions {
+ imo.BypassDocumentValidation = &b
+ return imo
+}
+
+// SetOrdered configures the ordered option. If true, when a write fails, the function will return without attempting
+// remaining writes. Defaults to true.
+func (imo *InsertManyOptions) SetOrdered(b bool) *InsertManyOptions {
+ imo.Ordered = &b
+ return imo
+}
+
+// MergeInsertManyOptions combines the argued InsertManyOptions into a single InsertManyOptions in a last-one-wins fashion
+func MergeInsertManyOptions(opts ...*InsertManyOptions) *InsertManyOptions {
+ imOpts := InsertMany()
+ for _, imo := range opts {
+ if imo == nil {
+ continue
+ }
+ if imo.BypassDocumentValidation != nil {
+ imOpts.BypassDocumentValidation = imo.BypassDocumentValidation
+ }
+ if imo.Ordered != nil {
+ imOpts.Ordered = imo.Ordered
+ }
+ }
+
+ return imOpts
+}
diff --git a/vendor/github.com/mongodb/mongo-go-driver/mongo/options/listcollectionsoptions.go b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/listcollectionsoptions.go
new file mode 100644
index 0000000..e44ad4a
--- /dev/null
+++ b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/listcollectionsoptions.go
@@ -0,0 +1,39 @@
+// Copyright (C) MongoDB, Inc. 2017-present.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+
+package options
+
+// ListCollectionsOptions represents all possible options for a listCollections command.
+type ListCollectionsOptions struct {
+ NameOnly *bool // If true, only the collection names will be returned.
+}
+
+// ListCollections creates a new *ListCollectionsOptions
+func ListCollections() *ListCollectionsOptions {
+ return &ListCollectionsOptions{}
+}
+
+// SetNameOnly specifies whether to return only the collection names.
+func (lc *ListCollectionsOptions) SetNameOnly(b bool) *ListCollectionsOptions {
+ lc.NameOnly = &b
+ return lc
+}
+
+// MergeListCollectionsOptions combines the given *ListCollectionsOptions into a single *ListCollectionsOptions in a
+// last one wins fashion.
+func MergeListCollectionsOptions(opts ...*ListCollectionsOptions) *ListCollectionsOptions {
+ lc := ListCollections()
+ for _, opt := range opts {
+ if opt == nil {
+ continue
+ }
+ if opt.NameOnly != nil {
+ lc.NameOnly = opt.NameOnly
+ }
+ }
+
+ return lc
+}
diff --git a/vendor/github.com/mongodb/mongo-go-driver/mongo/options/listdatabasesoptions.go b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/listdatabasesoptions.go
new file mode 100644
index 0000000..5efb6e8
--- /dev/null
+++ b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/listdatabasesoptions.go
@@ -0,0 +1,39 @@
+// Copyright (C) MongoDB, Inc. 2017-present.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+
+package options
+
+// ListDatabasesOptions represents all possible options for a listDatabases command.
+type ListDatabasesOptions struct {
+ NameOnly *bool // If true, only the database names will be returned.
+}
+
+// ListDatabases creates a new *ListDatabasesOptions
+func ListDatabases() *ListDatabasesOptions {
+ return &ListDatabasesOptions{}
+}
+
+// SetNameOnly specifies whether to return only the database names.
+func (ld *ListDatabasesOptions) SetNameOnly(b bool) *ListDatabasesOptions {
+ ld.NameOnly = &b
+ return ld
+}
+
+// MergeListDatabasesOptions combines the given *ListDatabasesOptions into a single *ListDatabasesOptions in a last one
+// wins fashion.
+func MergeListDatabasesOptions(opts ...*ListDatabasesOptions) *ListDatabasesOptions {
+ ld := ListDatabases()
+ for _, opt := range opts {
+ if opts == nil {
+ continue
+ }
+ if opt.NameOnly != nil {
+ ld.NameOnly = opt.NameOnly
+ }
+ }
+
+ return ld
+}
diff --git a/vendor/github.com/mongodb/mongo-go-driver/mongo/options/mongooptions.go b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/mongooptions.go
new file mode 100644
index 0000000..22f383b
--- /dev/null
+++ b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/mongooptions.go
@@ -0,0 +1,163 @@
+// Copyright (C) MongoDB, Inc. 2017-present.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+
+package options
+
+import (
+ "fmt"
+ "reflect"
+
+ "github.com/mongodb/mongo-go-driver/bson"
+ "github.com/mongodb/mongo-go-driver/bson/bsoncodec"
+ "github.com/mongodb/mongo-go-driver/x/bsonx"
+)
+
+// Collation allows users to specify language-specific rules for string comparison, such as
+// rules for lettercase and accent marks.
+type Collation struct {
+ Locale string `bson:",omitempty"` // The locale
+ CaseLevel bool `bson:",omitempty"` // The case level
+ CaseFirst string `bson:",omitempty"` // The case ordering
+ Strength int `bson:",omitempty"` // The number of comparision levels to use
+ NumericOrdering bool `bson:",omitempty"` // Whether to order numbers based on numerical order and not collation order
+ Alternate string `bson:",omitempty"` // Whether spaces and punctuation are considered base characters
+ MaxVariable string `bson:",omitempty"` // Which characters are affected by alternate: "shifted"
+ Normalization bool `bson:",omitempty"` // Causes text to be normalized into Unicode NFD
+ Backwards bool `bson:",omitempty"` // Causes secondary differences to be considered in reverse order, as it is done in the French language
+}
+
+// ToDocument converts the Collation to a *bsonx.Document
+func (co *Collation) ToDocument() bsonx.Doc {
+ doc := bsonx.Doc{}
+ if co.Locale != "" {
+ doc = append(doc, bsonx.Elem{"locale", bsonx.String(co.Locale)})
+ }
+ if co.CaseLevel {
+ doc = append(doc, bsonx.Elem{"caseLevel", bsonx.Boolean(true)})
+ }
+ if co.CaseFirst != "" {
+ doc = append(doc, bsonx.Elem{"caseFirst", bsonx.String(co.CaseFirst)})
+ }
+ if co.Strength != 0 {
+ doc = append(doc, bsonx.Elem{"strength", bsonx.Int32(int32(co.Strength))})
+ }
+ if co.NumericOrdering {
+ doc = append(doc, bsonx.Elem{"numericOrdering", bsonx.Boolean(true)})
+ }
+ if co.Alternate != "" {
+ doc = append(doc, bsonx.Elem{"alternate", bsonx.String(co.Alternate)})
+ }
+ if co.MaxVariable != "" {
+ doc = append(doc, bsonx.Elem{"maxVariable", bsonx.String(co.MaxVariable)})
+ }
+ if co.Normalization {
+ doc = append(doc, bsonx.Elem{"normalization", bsonx.Boolean(co.Normalization)})
+ }
+ if co.Backwards {
+ doc = append(doc, bsonx.Elem{"backwards", bsonx.Boolean(true)})
+ }
+ return doc
+}
+
+// CursorType specifies whether a cursor should close when the last data is retrieved. See
+// NonTailable, Tailable, and TailableAwait.
+type CursorType int8
+
+const (
+ // NonTailable specifies that a cursor should close after retrieving the last data.
+ NonTailable CursorType = iota
+ // Tailable specifies that a cursor should not close when the last data is retrieved and can be resumed later.
+ Tailable
+ // TailableAwait specifies that a cursor should not close when the last data is retrieved and
+ // that it should block for a certain amount of time for new data before returning no data.
+ TailableAwait
+)
+
+// ReturnDocument specifies whether a findAndUpdate operation should return the document as it was
+// before the update or as it is after the update.
+type ReturnDocument int8
+
+const (
+ // Before specifies that findAndUpdate should return the document as it was before the update.
+ Before ReturnDocument = iota
+ // After specifies that findAndUpdate should return the document as it is after the update.
+ After
+)
+
+// FullDocument specifies whether a change stream should include a copy of the entire document that was changed from
+// some time after the change occurred.
+type FullDocument string
+
+const (
+ // Default does not include a document copy
+ Default FullDocument = "default"
+ // UpdateLookup includes a delta describing the changes to the document and a copy of the entire document that
+ // was changed
+ UpdateLookup FullDocument = "updateLookup"
+)
+
+// ArrayFilters is used to hold filters for the array filters CRUD option. If a registry is nil, bson.DefaultRegistry
+// will be used when converting the filter interfaces to BSON.
+type ArrayFilters struct {
+ Registry *bsoncodec.Registry // The registry to use for converting filters. Defaults to bson.DefaultRegistry.
+ Filters []interface{} // The filters to apply
+}
+
+// ToArray builds a bsonx.Arr from the provided ArrayFilters.
+func (af *ArrayFilters) ToArray() (bsonx.Arr, error) {
+ docs := make([]bsonx.Doc, 0, len(af.Filters))
+ for _, f := range af.Filters {
+ d, err := transformDocument(af.Registry, f)
+ if err != nil {
+ return nil, err
+ }
+ docs = append(docs, d)
+ }
+
+ arr := bsonx.Arr{}
+ for _, doc := range docs {
+ arr = append(arr, bsonx.Document(doc))
+ }
+
+ return arr, nil
+}
+
+// MarshalError is returned when attempting to transform a value into a document
+// results in an error.
+type MarshalError struct {
+ Value interface{}
+ Err error
+}
+
+// Error implements the error interface.
+func (me MarshalError) Error() string {
+ return fmt.Sprintf("cannot transform type %s to a *bsonx.Document", reflect.TypeOf(me.Value))
+}
+
+var defaultRegistry = bson.DefaultRegistry
+
+func transformDocument(registry *bsoncodec.Registry, val interface{}) (bsonx.Doc, error) {
+ if val == nil {
+ return bsonx.Doc{}, nil
+ }
+ reg := defaultRegistry
+ if registry != nil {
+ reg = registry
+ }
+
+ if bs, ok := val.([]byte); ok {
+ // Slight optimization so we'll just use MarshalBSON and not go through the codec machinery.
+ val = bson.Raw(bs)
+ }
+
+ // TODO(skriptble): Use a pool of these instead.
+ buf := make([]byte, 0, 256)
+ b, err := bson.MarshalAppendWithRegistry(reg, buf, val)
+ if err != nil {
+ return nil, MarshalError{Value: val, Err: err}
+ }
+ return bsonx.ReadDoc(b)
+}
diff --git a/vendor/github.com/mongodb/mongo-go-driver/mongo/options/replaceoptions.go b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/replaceoptions.go
new file mode 100644
index 0000000..7a8c2ba
--- /dev/null
+++ b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/replaceoptions.go
@@ -0,0 +1,60 @@
+// Copyright (C) MongoDB, Inc. 2017-present.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+
+package options
+
+// ReplaceOptions represents all possible options to the replaceOne() function
+type ReplaceOptions struct {
+ BypassDocumentValidation *bool // If true, allows the write to opt-out of document level validation
+ Collation *Collation // Specifies a collation
+ Upsert *bool // When true, creates a new document if no document matches the query
+}
+
+// Replace returns a pointer to a new ReplaceOptions
+func Replace() *ReplaceOptions {
+ return &ReplaceOptions{}
+}
+
+// SetBypassDocumentValidation allows the write to opt-out of document level validation.
+// Valid for server versions >= 3.2. For servers < 3.2, this option is ignored.
+func (ro *ReplaceOptions) SetBypassDocumentValidation(b bool) *ReplaceOptions {
+ ro.BypassDocumentValidation = &b
+ return ro
+}
+
+// SetCollation specifies a collation.
+// Valid for servers >= 3.4
+func (ro *ReplaceOptions) SetCollation(c *Collation) *ReplaceOptions {
+ ro.Collation = c
+ return ro
+}
+
+// SetUpsert allows the creation of a new document if not document matches the query
+func (ro *ReplaceOptions) SetUpsert(b bool) *ReplaceOptions {
+ ro.Upsert = &b
+ return ro
+}
+
+// MergeReplaceOptions combines the argued ReplaceOptions into a single ReplaceOptions in a last-one-wins fashion
+func MergeReplaceOptions(opts ...*ReplaceOptions) *ReplaceOptions {
+ rOpts := Replace()
+ for _, ro := range opts {
+ if ro == nil {
+ continue
+ }
+ if ro.BypassDocumentValidation != nil {
+ rOpts.BypassDocumentValidation = ro.BypassDocumentValidation
+ }
+ if ro.Collation != nil {
+ rOpts.Collation = ro.Collation
+ }
+ if ro.Upsert != nil {
+ rOpts.Upsert = ro.Upsert
+ }
+ }
+
+ return rOpts
+}
diff --git a/vendor/github.com/mongodb/mongo-go-driver/mongo/options/runcmdoptions.go b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/runcmdoptions.go
new file mode 100644
index 0000000..c7c696d
--- /dev/null
+++ b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/runcmdoptions.go
@@ -0,0 +1,40 @@
+// Copyright (C) MongoDB, Inc. 2017-present.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+
+package options
+
+import "github.com/mongodb/mongo-go-driver/mongo/readpref"
+
+// RunCmdOptions represents all possible options for a runCommand operation.
+type RunCmdOptions struct {
+ ReadPreference *readpref.ReadPref // The read preference for the operation.
+}
+
+// RunCmd creates a new *RunCmdOptions
+func RunCmd() *RunCmdOptions {
+ return &RunCmdOptions{}
+}
+
+// SetReadPreference sets the read preference for the operation.
+func (rc *RunCmdOptions) SetReadPreference(rp *readpref.ReadPref) *RunCmdOptions {
+ rc.ReadPreference = rp
+ return rc
+}
+
+// MergeRunCmdOptions combines the given *RunCmdOptions into one *RunCmdOptions in a last one wins fashion.
+func MergeRunCmdOptions(opts ...*RunCmdOptions) *RunCmdOptions {
+ rc := RunCmd()
+ for _, opt := range opts {
+ if opt == nil {
+ continue
+ }
+ if opt.ReadPreference != nil {
+ rc.ReadPreference = opt.ReadPreference
+ }
+ }
+
+ return rc
+}
diff --git a/vendor/github.com/mongodb/mongo-go-driver/mongo/options/sessionoptions.go b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/sessionoptions.go
new file mode 100644
index 0000000..ffe45e6
--- /dev/null
+++ b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/sessionoptions.go
@@ -0,0 +1,79 @@
+// Copyright (C) MongoDB, Inc. 2017-present.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+
+package options
+
+import (
+ "github.com/mongodb/mongo-go-driver/mongo/readconcern"
+ "github.com/mongodb/mongo-go-driver/mongo/readpref"
+ "github.com/mongodb/mongo-go-driver/mongo/writeconcern"
+)
+
+// DefaultCausalConsistency is the default value for the CausalConsistency option.
+var DefaultCausalConsistency = true
+
+// SessionOptions represents all possible options for creating a new session.
+type SessionOptions struct {
+ CausalConsistency *bool // Specifies if reads should be causally consistent. Defaults to true.
+ DefaultReadConcern *readconcern.ReadConcern // The default read concern for transactions started in the session.
+ DefaultReadPreference *readpref.ReadPref // The default read preference for transactions started in the session.
+ DefaultWriteConcern *writeconcern.WriteConcern // The default write concern for transactions started in the session.
+}
+
+// Session creates a new *SessionOptions
+func Session() *SessionOptions {
+ return &SessionOptions{
+ CausalConsistency: &DefaultCausalConsistency,
+ }
+}
+
+// SetCausalConsistency specifies if a session should be causally consistent. Defaults to true.
+func (s *SessionOptions) SetCausalConsistency(b bool) *SessionOptions {
+ s.CausalConsistency = &b
+ return s
+}
+
+// SetDefaultReadConcern sets the default read concern for transactions started in a session.
+func (s *SessionOptions) SetDefaultReadConcern(rc *readconcern.ReadConcern) *SessionOptions {
+ s.DefaultReadConcern = rc
+ return s
+}
+
+// SetDefaultReadPreference sets the default read preference for transactions started in a session.
+func (s *SessionOptions) SetDefaultReadPreference(rp *readpref.ReadPref) *SessionOptions {
+ s.DefaultReadPreference = rp
+ return s
+}
+
+// SetDefaultWriteConcern sets the default write concern for transactions started in a session.
+func (s *SessionOptions) SetDefaultWriteConcern(wc *writeconcern.WriteConcern) *SessionOptions {
+ s.DefaultWriteConcern = wc
+ return s
+}
+
+// MergeSessionOptions combines the given *SessionOptions into a single *SessionOptions in a last one wins fashion.
+func MergeSessionOptions(opts ...*SessionOptions) *SessionOptions {
+ s := Session()
+ for _, opt := range opts {
+ if opt == nil {
+ continue
+ }
+ if opt.CausalConsistency != nil {
+ s.CausalConsistency = opt.CausalConsistency
+ }
+ if opt.DefaultReadConcern != nil {
+ s.DefaultReadConcern = opt.DefaultReadConcern
+ }
+ if opt.DefaultReadPreference != nil {
+ s.DefaultReadPreference = opt.DefaultReadPreference
+ }
+ if opt.DefaultWriteConcern != nil {
+ s.DefaultWriteConcern = opt.DefaultWriteConcern
+ }
+ }
+
+ return s
+}
diff --git a/vendor/github.com/mongodb/mongo-go-driver/mongo/options/transactionoptions.go b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/transactionoptions.go
new file mode 100644
index 0000000..5aec1b9
--- /dev/null
+++ b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/transactionoptions.go
@@ -0,0 +1,65 @@
+// Copyright (C) MongoDB, Inc. 2017-present.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+
+package options
+
+import (
+ "github.com/mongodb/mongo-go-driver/mongo/readconcern"
+ "github.com/mongodb/mongo-go-driver/mongo/readpref"
+ "github.com/mongodb/mongo-go-driver/mongo/writeconcern"
+)
+
+// TransactionOptions represents all possible options for starting a transaction.
+type TransactionOptions struct {
+ ReadConcern *readconcern.ReadConcern // The read concern for the transaction. Defaults to the session's read concern.
+ ReadPreference *readpref.ReadPref // The read preference for the transaction. Defaults to the session's read preference.
+ WriteConcern *writeconcern.WriteConcern // The write concern for the transaction. Defaults to the session's write concern.
+}
+
+// Transaction creates a new *TransactionOptions
+func Transaction() *TransactionOptions {
+ return &TransactionOptions{}
+}
+
+// SetReadConcern sets the read concern for the transaction.
+func (t *TransactionOptions) SetReadConcern(rc *readconcern.ReadConcern) *TransactionOptions {
+ t.ReadConcern = rc
+ return t
+}
+
+// SetReadPreference sets the read preference for the transaction.
+func (t *TransactionOptions) SetReadPreference(rp *readpref.ReadPref) *TransactionOptions {
+ t.ReadPreference = rp
+ return t
+}
+
+// SetWriteConcern sets the write concern for the transaction.
+func (t *TransactionOptions) SetWriteConcern(wc *writeconcern.WriteConcern) *TransactionOptions {
+ t.WriteConcern = wc
+ return t
+}
+
+// MergeTransactionOptions combines the given *TransactionOptions into a single *TransactionOptions in a last one wins
+// fashion.
+func MergeTransactionOptions(opts ...*TransactionOptions) *TransactionOptions {
+ t := Transaction()
+ for _, opt := range opts {
+ if opt == nil {
+ continue
+ }
+ if opt.ReadConcern != nil {
+ t.ReadConcern = opt.ReadConcern
+ }
+ if opt.ReadPreference != nil {
+ t.ReadPreference = opt.ReadPreference
+ }
+ if opt.WriteConcern != nil {
+ t.WriteConcern = opt.WriteConcern
+ }
+ }
+
+ return t
+}
diff --git a/vendor/github.com/mongodb/mongo-go-driver/mongo/options/updateoptions.go b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/updateoptions.go
new file mode 100644
index 0000000..468ccda
--- /dev/null
+++ b/vendor/github.com/mongodb/mongo-go-driver/mongo/options/updateoptions.go
@@ -0,0 +1,71 @@
+// Copyright (C) MongoDB, Inc. 2017-present.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+
+package options
+
+// UpdateOptions represents all possible options to the updateOne() and updateMany() functions
+type UpdateOptions struct {
+ ArrayFilters *ArrayFilters // A set of filters specifying to which array elements an update should apply
+ BypassDocumentValidation *bool // If true, allows the write to opt-out of document level validation
+ Collation *Collation // Specifies a collation
+ Upsert *bool // When true, creates a new document if no document matches the query
+}
+
+// Update returns a pointer to a new UpdateOptions
+func Update() *UpdateOptions {
+ return &UpdateOptions{}
+}
+
+// SetArrayFilters specifies a set of filters specifying to which array elements an update should apply
+// Valid for server versions >= 3.6.
+func (uo *UpdateOptions) SetArrayFilters(af ArrayFilters) *UpdateOptions {
+ uo.ArrayFilters = &af
+ return uo
+}
+
+// SetBypassDocumentValidation allows the write to opt-out of document level validation.
+// Valid for server versions >= 3.2. For servers < 3.2, this option is ignored.
+func (uo *UpdateOptions) SetBypassDocumentValidation(b bool) *UpdateOptions {
+ uo.BypassDocumentValidation = &b
+ return uo
+}
+
+// SetCollation specifies a collation.
+// Valid for server versions >= 3.4.
+func (uo *UpdateOptions) SetCollation(c *Collation) *UpdateOptions {
+ uo.Collation = c
+ return uo
+}
+
+// SetUpsert allows the creation of a new document if not document matches the query
+func (uo *UpdateOptions) SetUpsert(b bool) *UpdateOptions {
+ uo.Upsert = &b
+ return uo
+}
+
+// MergeUpdateOptions combines the argued UpdateOptions into a single UpdateOptions in a last-one-wins fashion
+func MergeUpdateOptions(opts ...*UpdateOptions) *UpdateOptions {
+ uOpts := Update()
+ for _, uo := range opts {
+ if uo == nil {
+ continue
+ }
+ if uo.ArrayFilters != nil {
+ uOpts.ArrayFilters = uo.ArrayFilters
+ }
+ if uo.BypassDocumentValidation != nil {
+ uOpts.BypassDocumentValidation = uo.BypassDocumentValidation
+ }
+ if uo.Collation != nil {
+ uOpts.Collation = uo.Collation
+ }
+ if uo.Upsert != nil {
+ uOpts.Upsert = uo.Upsert
+ }
+ }
+
+ return uOpts
+}