options
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Package options defines the optional configurations for the MongoDB Go Driver.
Index¶
- Constants
- Variables
- func BuildTLSConfig(tlsOpts map[string]interface{}) (*tls.Config, error)
- type AggregateOptions
- func (ao *AggregateOptions) SetAllowDiskUse(b bool) *AggregateOptions
- func (ao *AggregateOptions) SetBatchSize(i int32) *AggregateOptions
- func (ao *AggregateOptions) SetBypassDocumentValidation(b bool) *AggregateOptions
- func (ao *AggregateOptions) SetCollation(c *Collation) *AggregateOptions
- func (ao *AggregateOptions) SetComment(s string) *AggregateOptions
- func (ao *AggregateOptions) SetCustom(c bson.M) *AggregateOptions
- func (ao *AggregateOptions) SetHint(h interface{}) *AggregateOptions
- func (ao *AggregateOptions) SetLet(let interface{}) *AggregateOptions
- func (ao *AggregateOptions) SetMaxAwaitTime(d time.Duration) *AggregateOptions
- func (ao *AggregateOptions) SetMaxTime(d time.Duration) *AggregateOptions
- type ArrayFilters
- type AutoEncryptionOptions
- func (a *AutoEncryptionOptions) SetBypassAutoEncryption(bypass bool) *AutoEncryptionOptions
- func (a *AutoEncryptionOptions) SetBypassQueryAnalysis(bypass bool) *AutoEncryptionOptions
- func (a *AutoEncryptionOptions) SetEncryptedFieldsMap(ef map[string]interface{}) *AutoEncryptionOptions
- func (a *AutoEncryptionOptions) SetExtraOptions(extraOpts map[string]interface{}) *AutoEncryptionOptions
- func (a *AutoEncryptionOptions) SetKeyVaultClientOptions(opts *ClientOptions) *AutoEncryptionOptions
- func (a *AutoEncryptionOptions) SetKeyVaultNamespace(ns string) *AutoEncryptionOptions
- func (a *AutoEncryptionOptions) SetKmsProviders(providers map[string]map[string]interface{}) *AutoEncryptionOptions
- func (a *AutoEncryptionOptions) SetSchemaMap(schemaMap map[string]interface{}) *AutoEncryptionOptions
- func (a *AutoEncryptionOptions) SetTLSConfig(tlsOpts map[string]*tls.Config) *AutoEncryptionOptions
- type BSONOptions
- type BucketOptions
- func (b *BucketOptions) SetChunkSizeBytes(i int32) *BucketOptions
- func (b *BucketOptions) SetName(name string) *BucketOptions
- func (b *BucketOptions) SetReadConcern(rc *readconcern.ReadConcern) *BucketOptions
- func (b *BucketOptions) SetReadPreference(rp *readpref.ReadPref) *BucketOptions
- func (b *BucketOptions) SetWriteConcern(wc *writeconcern.WriteConcern) *BucketOptions
- type BulkWriteOptions
- type ChangeStreamOptions
- func (cso *ChangeStreamOptions) SetBatchSize(i int32) *ChangeStreamOptions
- func (cso *ChangeStreamOptions) SetCollation(c Collation) *ChangeStreamOptions
- func (cso *ChangeStreamOptions) SetComment(comment string) *ChangeStreamOptions
- func (cso *ChangeStreamOptions) SetCustom(c bson.M) *ChangeStreamOptions
- func (cso *ChangeStreamOptions) SetCustomPipeline(cp bson.M) *ChangeStreamOptions
- func (cso *ChangeStreamOptions) SetFullDocument(fd FullDocument) *ChangeStreamOptions
- func (cso *ChangeStreamOptions) SetFullDocumentBeforeChange(fdbc FullDocument) *ChangeStreamOptions
- func (cso *ChangeStreamOptions) SetMaxAwaitTime(d time.Duration) *ChangeStreamOptions
- func (cso *ChangeStreamOptions) SetResumeAfter(rt interface{}) *ChangeStreamOptions
- func (cso *ChangeStreamOptions) SetShowExpandedEvents(see bool) *ChangeStreamOptions
- func (cso *ChangeStreamOptions) SetStartAfter(sa interface{}) *ChangeStreamOptions
- func (cso *ChangeStreamOptions) SetStartAtOperationTime(t *primitive.Timestamp) *ChangeStreamOptions
- type ClientEncryptionOptions
- func (c *ClientEncryptionOptions) SetKeyVaultNamespace(ns string) *ClientEncryptionOptions
- func (c *ClientEncryptionOptions) SetKmsProviders(providers map[string]map[string]interface{}) *ClientEncryptionOptions
- func (c *ClientEncryptionOptions) SetTLSConfig(tlsOpts map[string]*tls.Config) *ClientEncryptionOptions
- type ClientOptions
- func (c *ClientOptions) ApplyURI(uri string) *ClientOptions
- func (c *ClientOptions) GetURI() string
- func (c *ClientOptions) SetAppName(s string) *ClientOptions
- func (c *ClientOptions) SetAuth(auth Credential) *ClientOptions
- func (c *ClientOptions) SetAutoEncryptionOptions(opts *AutoEncryptionOptions) *ClientOptions
- func (c *ClientOptions) SetBSONOptions(opts *BSONOptions) *ClientOptions
- func (c *ClientOptions) SetCompressors(comps []string) *ClientOptions
- func (c *ClientOptions) SetConnectTimeout(d time.Duration) *ClientOptions
- func (c *ClientOptions) SetDialer(d ContextDialer) *ClientOptions
- func (c *ClientOptions) SetDirect(b bool) *ClientOptions
- func (c *ClientOptions) SetDisableOCSPEndpointCheck(disableCheck bool) *ClientOptions
- func (c *ClientOptions) SetHTTPClient(client *http.Client) *ClientOptions
- func (c *ClientOptions) SetHeartbeatInterval(d time.Duration) *ClientOptions
- func (c *ClientOptions) SetHosts(s []string) *ClientOptions
- func (c *ClientOptions) SetLoadBalanced(lb bool) *ClientOptions
- func (c *ClientOptions) SetLocalThreshold(d time.Duration) *ClientOptions
- func (c *ClientOptions) SetLoggerOptions(opts *LoggerOptions) *ClientOptions
- func (c *ClientOptions) SetMaxConnIdleTime(d time.Duration) *ClientOptions
- func (c *ClientOptions) SetMaxConnecting(u uint64) *ClientOptions
- func (c *ClientOptions) SetMaxPoolSize(u uint64) *ClientOptions
- func (c *ClientOptions) SetMinPoolSize(u uint64) *ClientOptions
- func (c *ClientOptions) SetMonitor(m *event.CommandMonitor) *ClientOptions
- func (c *ClientOptions) SetPoolMonitor(m *event.PoolMonitor) *ClientOptions
- func (c *ClientOptions) SetReadConcern(rc *readconcern.ReadConcern) *ClientOptions
- func (c *ClientOptions) SetReadPreference(rp *readpref.ReadPref) *ClientOptions
- func (c *ClientOptions) SetRegistry(registry *bsoncodec.Registry) *ClientOptions
- func (c *ClientOptions) SetReplicaSet(s string) *ClientOptions
- func (c *ClientOptions) SetRetryReads(b bool) *ClientOptions
- func (c *ClientOptions) SetRetryWrites(b bool) *ClientOptions
- func (c *ClientOptions) SetSRVMaxHosts(srvMaxHosts int) *ClientOptions
- func (c *ClientOptions) SetSRVServiceName(srvName string) *ClientOptions
- func (c *ClientOptions) SetServerAPIOptions(opts *ServerAPIOptions) *ClientOptions
- func (c *ClientOptions) SetServerMonitor(m *event.ServerMonitor) *ClientOptions
- func (c *ClientOptions) SetServerMonitoringMode(mode string) *ClientOptions
- func (c *ClientOptions) SetServerSelectionTimeout(d time.Duration) *ClientOptions
- func (c *ClientOptions) SetSocketTimeout(d time.Duration) *ClientOptions
- func (c *ClientOptions) SetTLSConfig(cfg *tls.Config) *ClientOptions
- func (c *ClientOptions) SetTimeout(d time.Duration) *ClientOptions
- func (c *ClientOptions) SetWriteConcern(wc *writeconcern.WriteConcern) *ClientOptions
- func (c *ClientOptions) SetZlibLevel(level int) *ClientOptions
- func (c *ClientOptions) SetZstdLevel(level int) *ClientOptions
- func (c *ClientOptions) Validate() error
- type Collation
- type CollectionOptions
- func (c *CollectionOptions) SetBSONOptions(opts *BSONOptions) *CollectionOptions
- func (c *CollectionOptions) SetReadConcern(rc *readconcern.ReadConcern) *CollectionOptions
- func (c *CollectionOptions) SetReadPreference(rp *readpref.ReadPref) *CollectionOptions
- func (c *CollectionOptions) SetRegistry(r *bsoncodec.Registry) *CollectionOptions
- func (c *CollectionOptions) SetWriteConcern(wc *writeconcern.WriteConcern) *CollectionOptions
- type ContextDialer
- type CountOptions
- func (co *CountOptions) SetCollation(c *Collation) *CountOptions
- func (co *CountOptions) SetComment(c string) *CountOptions
- func (co *CountOptions) SetHint(h interface{}) *CountOptions
- func (co *CountOptions) SetLimit(i int64) *CountOptions
- func (co *CountOptions) SetMaxTime(d time.Duration) *CountOptions
- func (co *CountOptions) SetSkip(i int64) *CountOptions
- type CreateCollectionOptions
- func (c *CreateCollectionOptions) SetCapped(capped bool) *CreateCollectionOptions
- func (c *CreateCollectionOptions) SetChangeStreamPreAndPostImages(csppi interface{}) *CreateCollectionOptions
- func (c *CreateCollectionOptions) SetClusteredIndex(clusteredIndex interface{}) *CreateCollectionOptions
- func (c *CreateCollectionOptions) SetCollation(collation *Collation) *CreateCollectionOptions
- func (c *CreateCollectionOptions) SetDefaultIndexOptions(opts *DefaultIndexOptions) *CreateCollectionOptions
- func (c *CreateCollectionOptions) SetEncryptedFields(encryptedFields interface{}) *CreateCollectionOptions
- func (c *CreateCollectionOptions) SetExpireAfterSeconds(eas int64) *CreateCollectionOptions
- func (c *CreateCollectionOptions) SetMaxDocuments(max int64) *CreateCollectionOptions
- func (c *CreateCollectionOptions) SetSizeInBytes(size int64) *CreateCollectionOptions
- func (c *CreateCollectionOptions) SetStorageEngine(storageEngine interface{}) *CreateCollectionOptions
- func (c *CreateCollectionOptions) SetTimeSeriesOptions(timeSeriesOpts *TimeSeriesOptions) *CreateCollectionOptions
- func (c *CreateCollectionOptions) SetValidationAction(action string) *CreateCollectionOptions
- func (c *CreateCollectionOptions) SetValidationLevel(level string) *CreateCollectionOptions
- func (c *CreateCollectionOptions) SetValidator(validator interface{}) *CreateCollectionOptions
- type CreateIndexesOptions
- func (c *CreateIndexesOptions) SetCommitQuorumInt(quorum int32) *CreateIndexesOptions
- func (c *CreateIndexesOptions) SetCommitQuorumMajority() *CreateIndexesOptions
- func (c *CreateIndexesOptions) SetCommitQuorumString(quorum string) *CreateIndexesOptions
- func (c *CreateIndexesOptions) SetCommitQuorumVotingMembers() *CreateIndexesOptions
- func (c *CreateIndexesOptions) SetMaxTime(d time.Duration) *CreateIndexesOptions
- type CreateSearchIndexesOptions
- type CreateViewOptions
- type Credential
- type CursorType
- type DataKeyOptions
- type DatabaseOptions
- func (d *DatabaseOptions) SetBSONOptions(opts *BSONOptions) *DatabaseOptions
- func (d *DatabaseOptions) SetReadConcern(rc *readconcern.ReadConcern) *DatabaseOptions
- func (d *DatabaseOptions) SetReadPreference(rp *readpref.ReadPref) *DatabaseOptions
- func (d *DatabaseOptions) SetRegistry(r *bsoncodec.Registry) *DatabaseOptions
- func (d *DatabaseOptions) SetWriteConcern(wc *writeconcern.WriteConcern) *DatabaseOptions
- type DefaultIndexOptions
- type DeleteOptions
- type DistinctOptions
- type DropIndexesOptions
- type DropSearchIndexOptions
- type EncryptOptions
- func (e *EncryptOptions) SetAlgorithm(algorithm string) *EncryptOptions
- func (e *EncryptOptions) SetContentionFactor(contentionFactor int64) *EncryptOptions
- func (e *EncryptOptions) SetKeyAltName(keyAltName string) *EncryptOptions
- func (e *EncryptOptions) SetKeyID(keyID primitive.Binary) *EncryptOptions
- func (e *EncryptOptions) SetQueryType(queryType string) *EncryptOptions
- func (e *EncryptOptions) SetRangeOptions(ro RangeOptions) *EncryptOptions
- type EstimatedDocumentCountOptions
- type FindOneAndDeleteOptions
- func (f *FindOneAndDeleteOptions) SetCollation(collation *Collation) *FindOneAndDeleteOptions
- func (f *FindOneAndDeleteOptions) SetComment(comment interface{}) *FindOneAndDeleteOptions
- func (f *FindOneAndDeleteOptions) SetHint(hint interface{}) *FindOneAndDeleteOptions
- func (f *FindOneAndDeleteOptions) SetLet(let interface{}) *FindOneAndDeleteOptions
- func (f *FindOneAndDeleteOptions) SetMaxTime(d time.Duration) *FindOneAndDeleteOptions
- func (f *FindOneAndDeleteOptions) SetProjection(projection interface{}) *FindOneAndDeleteOptions
- func (f *FindOneAndDeleteOptions) SetSort(sort interface{}) *FindOneAndDeleteOptions
- type FindOneAndReplaceOptions
- func (f *FindOneAndReplaceOptions) SetBypassDocumentValidation(b bool) *FindOneAndReplaceOptions
- func (f *FindOneAndReplaceOptions) SetCollation(collation *Collation) *FindOneAndReplaceOptions
- func (f *FindOneAndReplaceOptions) SetComment(comment interface{}) *FindOneAndReplaceOptions
- func (f *FindOneAndReplaceOptions) SetHint(hint interface{}) *FindOneAndReplaceOptions
- func (f *FindOneAndReplaceOptions) SetLet(let interface{}) *FindOneAndReplaceOptions
- func (f *FindOneAndReplaceOptions) SetMaxTime(d time.Duration) *FindOneAndReplaceOptions
- func (f *FindOneAndReplaceOptions) SetProjection(projection interface{}) *FindOneAndReplaceOptions
- func (f *FindOneAndReplaceOptions) SetReturnDocument(rd ReturnDocument) *FindOneAndReplaceOptions
- func (f *FindOneAndReplaceOptions) SetSort(sort interface{}) *FindOneAndReplaceOptions
- func (f *FindOneAndReplaceOptions) SetUpsert(b bool) *FindOneAndReplaceOptions
- type FindOneAndUpdateOptions
- func (f *FindOneAndUpdateOptions) SetArrayFilters(filters ArrayFilters) *FindOneAndUpdateOptions
- func (f *FindOneAndUpdateOptions) SetBypassDocumentValidation(b bool) *FindOneAndUpdateOptions
- func (f *FindOneAndUpdateOptions) SetCollation(collation *Collation) *FindOneAndUpdateOptions
- func (f *FindOneAndUpdateOptions) SetComment(comment interface{}) *FindOneAndUpdateOptions
- func (f *FindOneAndUpdateOptions) SetHint(hint interface{}) *FindOneAndUpdateOptions
- func (f *FindOneAndUpdateOptions) SetLet(let interface{}) *FindOneAndUpdateOptions
- func (f *FindOneAndUpdateOptions) SetMaxTime(d time.Duration) *FindOneAndUpdateOptions
- func (f *FindOneAndUpdateOptions) SetProjection(projection interface{}) *FindOneAndUpdateOptions
- func (f *FindOneAndUpdateOptions) SetReturnDocument(rd ReturnDocument) *FindOneAndUpdateOptions
- func (f *FindOneAndUpdateOptions) SetSort(sort interface{}) *FindOneAndUpdateOptions
- func (f *FindOneAndUpdateOptions) SetUpsert(b bool) *FindOneAndUpdateOptions
- type FindOneOptions
- func (f *FindOneOptions) SetAllowPartialResults(b bool) *FindOneOptions
- func (f *FindOneOptions) SetBatchSize(i int32) *FindOneOptionsdeprecated
- func (f *FindOneOptions) SetCollation(collation *Collation) *FindOneOptions
- func (f *FindOneOptions) SetComment(comment string) *FindOneOptions
- func (f *FindOneOptions) SetCursorType(ct CursorType) *FindOneOptionsdeprecated
- func (f *FindOneOptions) SetHint(hint interface{}) *FindOneOptions
- func (f *FindOneOptions) SetMax(max interface{}) *FindOneOptions
- func (f *FindOneOptions) SetMaxAwaitTime(d time.Duration) *FindOneOptionsdeprecated
- func (f *FindOneOptions) SetMaxTime(d time.Duration) *FindOneOptions
- func (f *FindOneOptions) SetMin(min interface{}) *FindOneOptions
- func (f *FindOneOptions) SetNoCursorTimeout(b bool) *FindOneOptionsdeprecated
- func (f *FindOneOptions) SetOplogReplay(b bool) *FindOneOptionsdeprecated
- func (f *FindOneOptions) SetProjection(projection interface{}) *FindOneOptions
- func (f *FindOneOptions) SetReturnKey(b bool) *FindOneOptions
- func (f *FindOneOptions) SetShowRecordID(b bool) *FindOneOptions
- func (f *FindOneOptions) SetSkip(i int64) *FindOneOptions
- func (f *FindOneOptions) SetSnapshot(b bool) *FindOneOptionsdeprecated
- func (f *FindOneOptions) SetSort(sort interface{}) *FindOneOptions
- type FindOptions
- func (f *FindOptions) SetAllowDiskUse(b bool) *FindOptions
- func (f *FindOptions) SetAllowPartialResults(b bool) *FindOptions
- func (f *FindOptions) SetBatchSize(i int32) *FindOptions
- func (f *FindOptions) SetCollation(collation *Collation) *FindOptions
- func (f *FindOptions) SetComment(comment string) *FindOptions
- func (f *FindOptions) SetCursorType(ct CursorType) *FindOptions
- func (f *FindOptions) SetHint(hint interface{}) *FindOptions
- func (f *FindOptions) SetLet(let interface{}) *FindOptions
- func (f *FindOptions) SetLimit(i int64) *FindOptions
- func (f *FindOptions) SetMax(max interface{}) *FindOptions
- func (f *FindOptions) SetMaxAwaitTime(d time.Duration) *FindOptions
- func (f *FindOptions) SetMaxTime(d time.Duration) *FindOptions
- func (f *FindOptions) SetMin(min interface{}) *FindOptions
- func (f *FindOptions) SetNoCursorTimeout(b bool) *FindOptions
- func (f *FindOptions) SetOplogReplay(b bool) *FindOptionsdeprecated
- func (f *FindOptions) SetProjection(projection interface{}) *FindOptions
- func (f *FindOptions) SetReturnKey(b bool) *FindOptions
- func (f *FindOptions) SetShowRecordID(b bool) *FindOptions
- func (f *FindOptions) SetSkip(i int64) *FindOptions
- func (f *FindOptions) SetSnapshot(b bool) *FindOptionsdeprecated
- func (f *FindOptions) SetSort(sort interface{}) *FindOptions
- type FullDocument
- type GridFSFindOptions
- func (f *GridFSFindOptions) SetAllowDiskUse(b bool) *GridFSFindOptions
- func (f *GridFSFindOptions) SetBatchSize(i int32) *GridFSFindOptions
- func (f *GridFSFindOptions) SetLimit(i int32) *GridFSFindOptions
- func (f *GridFSFindOptions) SetMaxTime(d time.Duration) *GridFSFindOptions
- func (f *GridFSFindOptions) SetNoCursorTimeout(b bool) *GridFSFindOptions
- func (f *GridFSFindOptions) SetSkip(i int32) *GridFSFindOptions
- func (f *GridFSFindOptions) SetSort(sort interface{}) *GridFSFindOptions
- type IDPInfo
- type IndexOptions
- func (i *IndexOptions) SetBackground(background bool) *IndexOptionsdeprecated
- func (i *IndexOptions) SetBits(bits int32) *IndexOptions
- func (i *IndexOptions) SetBucketSize(bucketSize int32) *IndexOptions
- func (i *IndexOptions) SetCollation(collation *Collation) *IndexOptions
- func (i *IndexOptions) SetDefaultLanguage(language string) *IndexOptions
- func (i *IndexOptions) SetExpireAfterSeconds(seconds int32) *IndexOptions
- func (i *IndexOptions) SetHidden(hidden bool) *IndexOptions
- func (i *IndexOptions) SetLanguageOverride(override string) *IndexOptions
- func (i *IndexOptions) SetMax(max float64) *IndexOptions
- func (i *IndexOptions) SetMin(min float64) *IndexOptions
- func (i *IndexOptions) SetName(name string) *IndexOptions
- func (i *IndexOptions) SetPartialFilterExpression(expression interface{}) *IndexOptions
- func (i *IndexOptions) SetSparse(sparse bool) *IndexOptions
- func (i *IndexOptions) SetSphereVersion(version int32) *IndexOptions
- func (i *IndexOptions) SetStorageEngine(engine interface{}) *IndexOptions
- func (i *IndexOptions) SetTextVersion(version int32) *IndexOptions
- func (i *IndexOptions) SetUnique(unique bool) *IndexOptions
- func (i *IndexOptions) SetVersion(version int32) *IndexOptions
- func (i *IndexOptions) SetWeights(weights interface{}) *IndexOptions
- func (i *IndexOptions) SetWildcardProjection(wildcardProjection interface{}) *IndexOptions
- type InsertManyOptions
- type InsertOneOptions
- type ListCollectionsOptions
- type ListDatabasesOptions
- type ListIndexesOptions
- type ListSearchIndexesOptions
- type LogComponent
- type LogLevel
- type LogSink
- type LoggerOptions
- type MarshalErrordeprecated
- func (me MarshalError) Error() stringdeprecated
- type NameOptions
- type OIDCArgs
- type OIDCCallback
- type OIDCCredential
- type RangeOptions
- func (ro *RangeOptions) SetMax(max bson.RawValue) *RangeOptions
- func (ro *RangeOptions) SetMin(min bson.RawValue) *RangeOptions
- func (ro *RangeOptions) SetPrecision(precision int32) *RangeOptions
- func (ro *RangeOptions) SetSparsity(sparsity int64) *RangeOptions
- func (ro *RangeOptions) SetTrimFactor(trimFactor int32) *RangeOptions
- type ReplaceOptions
- func (ro *ReplaceOptions) SetBypassDocumentValidation(b bool) *ReplaceOptions
- func (ro *ReplaceOptions) SetCollation(c *Collation) *ReplaceOptions
- func (ro *ReplaceOptions) SetComment(comment interface{}) *ReplaceOptions
- func (ro *ReplaceOptions) SetHint(h interface{}) *ReplaceOptions
- func (ro *ReplaceOptions) SetLet(l interface{}) *ReplaceOptions
- func (ro *ReplaceOptions) SetUpsert(b bool) *ReplaceOptions
- type ReturnDocument
- type RewrapManyDataKeyOptions
- type RunCmdOptions
- type SearchIndexesOptions
- type ServerAPIOptions
- type ServerAPIVersion
- type SessionOptions
- func (s *SessionOptions) SetCausalConsistency(b bool) *SessionOptions
- func (s *SessionOptions) SetDefaultMaxCommitTime(mct *time.Duration) *SessionOptions
- func (s *SessionOptions) SetDefaultReadConcern(rc *readconcern.ReadConcern) *SessionOptions
- func (s *SessionOptions) SetDefaultReadPreference(rp *readpref.ReadPref) *SessionOptions
- func (s *SessionOptions) SetDefaultWriteConcern(wc *writeconcern.WriteConcern) *SessionOptions
- func (s *SessionOptions) SetSnapshot(b bool) *SessionOptions
- type TimeSeriesOptions
- func (tso *TimeSeriesOptions) SetBucketMaxSpan(dur time.Duration) *TimeSeriesOptions
- func (tso *TimeSeriesOptions) SetBucketRounding(dur time.Duration) *TimeSeriesOptions
- func (tso *TimeSeriesOptions) SetGranularity(granularity string) *TimeSeriesOptions
- func (tso *TimeSeriesOptions) SetMetaField(metaField string) *TimeSeriesOptions
- func (tso *TimeSeriesOptions) SetTimeField(timeField string) *TimeSeriesOptions
- type TransactionOptions
- func (t *TransactionOptions) SetMaxCommitTime(mct *time.Duration) *TransactionOptions
- func (t *TransactionOptions) SetReadConcern(rc *readconcern.ReadConcern) *TransactionOptions
- func (t *TransactionOptions) SetReadPreference(rp *readpref.ReadPref) *TransactionOptions
- func (t *TransactionOptions) SetWriteConcern(wc *writeconcern.WriteConcern) *TransactionOptions
- type UpdateOptions
- func (uo *UpdateOptions) SetArrayFilters(af ArrayFilters) *UpdateOptions
- func (uo *UpdateOptions) SetBypassDocumentValidation(b bool) *UpdateOptions
- func (uo *UpdateOptions) SetCollation(c *Collation) *UpdateOptions
- func (uo *UpdateOptions) SetComment(comment interface{}) *UpdateOptions
- func (uo *UpdateOptions) SetHint(h interface{}) *UpdateOptions
- func (uo *UpdateOptions) SetLet(l interface{}) *UpdateOptions
- func (uo *UpdateOptions) SetUpsert(b bool) *UpdateOptions
- type UpdateSearchIndexOptions
- type UploadOptions
Examples¶
Constants¶
const (// ServerMonitoringModeAuto indicates that the client will behave like "poll"// mode when running on a FaaS (Function as a Service) platform, or like// "stream" mode otherwise. The client detects its execution environment by// following the rules for generating the "client.env" handshake metadata field// as specified in the MongoDB Handshake specification. This is the default// mode.ServerMonitoringModeAuto =connstring.ServerMonitoringModeAuto// ServerMonitoringModePoll indicates that the client will periodically check// the server using a hello or legacy hello command and then sleep for// heartbeatFrequencyMS milliseconds before running another check.ServerMonitoringModePoll =connstring.ServerMonitoringModePoll// ServerMonitoringModeStream indicates that the client will use a streaming// protocol when the server supports it. The streaming protocol optimally// reduces the time it takes for a client to discover server state changes.ServerMonitoringModeStream =connstring.ServerMonitoringModeStream)
const (QueryTypeEqualitystring = "equality")These constants specify valid values for QueryTypeQueryType is used for Queryable Encryption.
Variables¶
var DefaultCausalConsistency =trueDefaultCausalConsistency is the default value for the CausalConsistency option.
var DefaultChunkSizeint32 = 255 * 1024DefaultChunkSize is the default size of each file chunk in bytes (255 KiB).
var DefaultName = "fs"DefaultName is the default name for a GridFS bucket.
var DefaultOrdered =trueDefaultOrdered is the default value for the Ordered option in BulkWriteOptions.
var DefaultRevisionint32 = -1DefaultRevision is the default revision number for a download by name operation.
Functions¶
funcBuildTLSConfig¶added inv1.8.0
BuildTLSConfig specifies tls.Config options for each KMS provider to use to configure TLS on all connections createdto the KMS provider. The input map should contain a mapping from each KMS provider to a document containing the necessaryoptions, as follows:
{"kmip": {"tlsCertificateKeyFile": "foo.pem","tlsCAFile": "fooCA.pem"}}Currently, the following TLS options are supported:
1. "tlsCertificateKeyFile" (or "sslClientCertificateKeyFile"): The "tlsCertificateKeyFile" option specifies a path tothe client certificate and private key, which must be concatenated into one file.
2. "tlsCertificateKeyFilePassword" (or "sslClientCertificateKeyPassword"): Specify the password to decrypt the clientprivate key file (e.g. "tlsCertificateKeyFilePassword=password").
3. "tlsCaFile" (or "sslCertificateAuthorityFile"): Specify the path to a single or bundle of certificate authoritiesto be considered trusted when making a TLS connection (e.g. "tlsCaFile=/path/to/caFile").
This should only be used to set custom TLS options. By default, the connection will use an empty tls.Config{} with MinVersion set to tls.VersionTLS12.
Types¶
typeAggregateOptions¶added inv0.1.0
type AggregateOptions struct {// If true, the operation can write to temporary files in the _tmp subdirectory of the database directory path on// the server. The default value is false.AllowDiskUse *bool// The maximum number of documents to be included in each batch returned by the server.BatchSize *int32// If true, writes executed as part of the operation will opt out of document-level validation on the server. This// option is valid for MongoDB versions >= 3.2 and is ignored for previous server versions. The default value is// false. Seehttps://www.mongodb.com/docs/manual/core/schema-validation/ for more information about document// validation.BypassDocumentValidation *bool// Specifies a collation to use for string comparisons during the operation. This option is only valid for MongoDB// versions >= 3.4. For previous server versions, the driver will return an error if this option is used. The// default value is nil, which means the default collation of the collection will be used.Collation *Collation// The maximum amount of time that the query can run on the server. The default value is nil, meaning that there// is no time limit for query execution.//// NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeout option may be used// in its place to control the amount of time that a single operation can run before returning an error. MaxTime// is ignored if Timeout is set on the client.MaxTime *time.Duration// The maximum amount of time that the server should wait for new documents to satisfy a tailable cursor query.// This option is only valid for MongoDB versions >= 3.2 and is ignored for previous server versions.MaxAwaitTime *time.Duration// A string that will be included in server logs, profiling logs, and currentOp queries to help trace the operation.// The default is nil, which means that no comment will be included in the logs.Comment *string// The index to use for the aggregation. This should either be the index name as a string or the index specification// as a document. The hint does not apply to $lookup and $graphLookup aggregation stages. The driver will return an// error if the hint parameter is a multi-key map. The default value is nil, which means that no hint will be sent.Hint interface{}// Specifies parameters for the aggregate expression. This option is only valid for MongoDB versions >= 5.0. Older// servers will report an error for using this option. This must be a document mapping parameter names to values.// Values must be constant or closed expressions that do not reference document fields. Parameters can then be// accessed as variables in an aggregate expression context (e.g. "$$var").Let interface{}// Custom options to be added to aggregate expression. Key-value pairs of the BSON map should correlate with desired// option names and values. Values must be Marshalable. Custom options may conflict with non-custom options, and custom// options bypass client-side validation. Prefer using non-custom options where possible.Custombson.M}AggregateOptions represents options that can be used to configure an Aggregate operation.
funcAggregate¶added inv0.1.0
func Aggregate() *AggregateOptions
Aggregate creates a new AggregateOptions instance.
funcMergeAggregateOptionsdeprecatedadded inv0.1.0
func MergeAggregateOptions(opts ...*AggregateOptions) *AggregateOptions
MergeAggregateOptions combines the given AggregateOptions instances into a single AggregateOptions in a last-one-winsfashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create asingle options struct instead.
func (*AggregateOptions)SetAllowDiskUse¶added inv0.1.0
func (ao *AggregateOptions) SetAllowDiskUse(bbool) *AggregateOptions
SetAllowDiskUse sets the value for the AllowDiskUse field.
func (*AggregateOptions)SetBatchSize¶added inv0.1.0
func (ao *AggregateOptions) SetBatchSize(iint32) *AggregateOptions
SetBatchSize sets the value for the BatchSize field.
func (*AggregateOptions)SetBypassDocumentValidation¶added inv0.1.0
func (ao *AggregateOptions) SetBypassDocumentValidation(bbool) *AggregateOptions
SetBypassDocumentValidation sets the value for the BypassDocumentValidation field.
func (*AggregateOptions)SetCollation¶added inv0.1.0
func (ao *AggregateOptions) SetCollation(c *Collation) *AggregateOptions
SetCollation sets the value for the Collation field.
func (*AggregateOptions)SetComment¶added inv0.1.0
func (ao *AggregateOptions) SetComment(sstring) *AggregateOptions
SetComment sets the value for the Comment field.
func (*AggregateOptions)SetCustom¶added inv1.9.0
func (ao *AggregateOptions) SetCustom(cbson.M) *AggregateOptions
SetCustom sets the value for the Custom field. Key-value pairs of the BSON map should correlatewith desired option names and values. Values must be Marshalable. Custom options may conflictwith non-custom options, and custom options bypass client-side validation. Prefer using non-customoptions where possible.
func (*AggregateOptions)SetHint¶added inv0.1.0
func (ao *AggregateOptions) SetHint(h interface{}) *AggregateOptions
SetHint sets the value for the Hint field.
func (*AggregateOptions)SetLet¶added inv1.6.0
func (ao *AggregateOptions) SetLet(let interface{}) *AggregateOptions
SetLet sets the value for the Let field.
func (*AggregateOptions)SetMaxAwaitTime¶added inv0.1.0
func (ao *AggregateOptions) SetMaxAwaitTime(dtime.Duration) *AggregateOptions
SetMaxAwaitTime sets the value for the MaxAwaitTime field.
func (*AggregateOptions)SetMaxTime¶added inv0.1.0
func (ao *AggregateOptions) SetMaxTime(dtime.Duration) *AggregateOptions
SetMaxTime sets the value for the MaxTime field.
NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeoutoption may be used in its place to control the amount of time that a single operation canrun before returning an error. MaxTime is ignored if Timeout is set on the client.
typeArrayFilters¶added inv0.1.0
type ArrayFilters struct {// Registry is the registry to use for converting filters. Defaults to bson.DefaultRegistry.//// Deprecated: Marshaling ArrayFilters to BSON will not be supported in Go Driver 2.0.Registry *bsoncodec.RegistryFilters []interface{}// The filters to apply}ArrayFilters is used to hold filters for the array filters CRUD option. If a registry is nil, bson.DefaultRegistrywill be used when converting the filter interfaces to BSON.
func (*ArrayFilters)ToArraydeprecatedadded inv0.1.0
func (af *ArrayFilters) ToArray() ([]bson.Raw,error)
ToArray builds a []bson.Raw from the provided ArrayFilters.
Deprecated: Marshaling ArrayFilters to BSON will not be supported in Go Driver 2.0.
func (*ArrayFilters)ToArrayDocumentdeprecatedadded inv1.1.0
func (af *ArrayFilters) ToArrayDocument() (bson.Raw,error)
ToArrayDocument builds a BSON array for the array filters CRUD option. If the registry for af is nil,bson.DefaultRegistry will be used when converting the filter interfaces to BSON.
Deprecated: Marshaling ArrayFilters to BSON will not be supported in Go Driver 2.0.
typeAutoEncryptionOptions¶added inv1.2.0
type AutoEncryptionOptions struct {KeyVaultClientOptions *ClientOptionsKeyVaultNamespacestringKmsProviders map[string]map[string]interface{}SchemaMap map[string]interface{}BypassAutoEncryption *boolExtraOptions map[string]interface{}TLSConfig map[string]*tls.ConfigHTTPClient *http.ClientEncryptedFieldsMap map[string]interface{}BypassQueryAnalysis *bool}AutoEncryptionOptions represents options used to configure auto encryption/decryption behavior for a mongo.Clientinstance.
Automatic encryption is an enterprise only feature that only applies to operations on a collection. Automaticencryption is not supported for operations on a database or view, and operations that are not bypassed will resultin error. Too bypass automatic encryption for all operations, set BypassAutoEncryption=true.
Auto encryption requires the authenticated user to have the listCollections privilege action.
If automatic encryption fails on an operation, use a MongoClient configured with bypassAutoEncryption=true and useClientEncryption.encrypt() to manually encrypt values.
Enabling Client Side Encryption reduces the maximum document and message size (using a maxBsonObjectSize of 2MiB andmaxMessageSizeBytes of 6MB) and may have a negative performance impact.
funcAutoEncryption¶added inv1.2.0
func AutoEncryption() *AutoEncryptionOptions
AutoEncryption creates a new AutoEncryptionOptions configured with default values.
funcMergeAutoEncryptionOptionsdeprecatedadded inv1.2.0
func MergeAutoEncryptionOptions(opts ...*AutoEncryptionOptions) *AutoEncryptionOptions
MergeAutoEncryptionOptions combines the argued AutoEncryptionOptions in a last-one wins fashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create asingle options struct instead.
func (*AutoEncryptionOptions)SetBypassAutoEncryption¶added inv1.2.0
func (a *AutoEncryptionOptions) SetBypassAutoEncryption(bypassbool) *AutoEncryptionOptions
SetBypassAutoEncryption specifies whether or not auto encryption should be done.
If this is unset or false and target mongo.Client being configured has an unlimited connection pool size(i.e. maxPoolSize=0), it is reused in the process of auto encryption.Otherwise, if the target mongo.Client has a limited connection pool size, a separate internal mongo.Client is used(and created if necessary). The internal mongo.Client may be shared for key vault operations (if KeyVaultClient isunset). The internal mongo.Client is configured with the same options as the target mongo.Client except minPoolSizeis set to 0 and AutoEncryptionOptions is omitted.
func (*AutoEncryptionOptions)SetBypassQueryAnalysis¶added inv1.10.0
func (a *AutoEncryptionOptions) SetBypassQueryAnalysis(bypassbool) *AutoEncryptionOptions
SetBypassQueryAnalysis specifies whether or not query analysis should be used for automatic encryption.Use this option when using explicit encryption with Queryable Encryption.
func (*AutoEncryptionOptions)SetEncryptedFieldsMap¶added inv1.10.0
func (a *AutoEncryptionOptions) SetEncryptedFieldsMap(ef map[string]interface{}) *AutoEncryptionOptions
SetEncryptedFieldsMap specifies a map from namespace to local EncryptedFieldsMap document.EncryptedFieldsMap is used for Queryable Encryption.
func (*AutoEncryptionOptions)SetExtraOptions¶added inv1.2.0
func (a *AutoEncryptionOptions) SetExtraOptions(extraOpts map[string]interface{}) *AutoEncryptionOptions
SetExtraOptions specifies a map of options to configure the mongocryptd process or mongo_crypt shared library.
Supported Extra Options¶
"mongocryptdURI" - The mongocryptd URI. Allows setting a custom URI used to communicate with themongocryptd process. The default is "mongodb://localhost:27020", which works with the defaultmongocryptd process spawned by the Client. Must be a string.
"mongocryptdBypassSpawn" - If set to true, the Client will not attempt to spawn a mongocryptdprocess. Must be a bool.
"mongocryptdSpawnPath" - The path used when spawning mongocryptd.Defaults to empty string and spawns mongocryptd from system path. Must be a string.
"mongocryptdSpawnArgs" - Command line arguments passed when spawning mongocryptd.Defaults to ["--idleShutdownTimeoutSecs=60"]. Must be an array of strings.
"cryptSharedLibRequired" - If set to true, Client creation will return an error if thecrypt_shared library is not loaded. If unset or set to false, Client creation will not return anerror if the crypt_shared library is not loaded. The default is unset. Must be a bool.
"cryptSharedLibPath" - The crypt_shared library override path. This must be the path to thecrypt_shared dynamic library file (for example, a .so, .dll, or .dylib file), not the directorythat contains it. If the override path is a relative path, it will be resolved relative to theworking directory of the process. If the override path is a relative path and the first pathcomponent is the literal string "$ORIGIN", the "$ORIGIN" component will be replaced by theabsolute path to the directory containing the linked libmongocrypt library. Setting an overridepath disables the default system library search path. If an override path is specified but thecrypt_shared library cannot be loaded, Client creation will return an error. Must be a string.
func (*AutoEncryptionOptions)SetKeyVaultClientOptions¶added inv1.2.0
func (a *AutoEncryptionOptions) SetKeyVaultClientOptions(opts *ClientOptions) *AutoEncryptionOptions
SetKeyVaultClientOptions specifies options for the client used to communicate with the key vault collection.
If this is set, it is used to create an internal mongo.Client.Otherwise, if the target mongo.Client being configured has an unlimited connection pool size (i.e. maxPoolSize=0),it is reused to interact with the key vault collection.Otherwise, if the target mongo.Client has a limited connection pool size, a separate internal mongo.Client is used(and created if necessary). The internal mongo.Client may be shared during automatic encryption (ifBypassAutomaticEncryption is false). The internal mongo.Client is configured with the same options as the targetmongo.Client except minPoolSize is set to 0 and AutoEncryptionOptions is omitted.
func (*AutoEncryptionOptions)SetKeyVaultNamespace¶added inv1.2.0
func (a *AutoEncryptionOptions) SetKeyVaultNamespace(nsstring) *AutoEncryptionOptions
SetKeyVaultNamespace specifies the namespace of the key vault collection. This is required.
func (*AutoEncryptionOptions)SetKmsProviders¶added inv1.2.0
func (a *AutoEncryptionOptions) SetKmsProviders(providers map[string]map[string]interface{}) *AutoEncryptionOptions
SetKmsProviders specifies options for KMS providers. This is required.
func (*AutoEncryptionOptions)SetSchemaMap¶added inv1.2.0
func (a *AutoEncryptionOptions) SetSchemaMap(schemaMap map[string]interface{}) *AutoEncryptionOptions
SetSchemaMap specifies a map from namespace to local schema document. Schemas supplied in the schemaMap only applyto configuring automatic encryption for client side encryption. Other validation rules in the JSON schema will notbe enforced by the driver and will result in an error.
Supplying a schemaMap provides more security than relying on JSON Schemas obtained from the server. It protectsagainst a malicious server advertising a false JSON Schema, which could trick the client into sending unencrypteddata that should be encrypted.
func (*AutoEncryptionOptions)SetTLSConfig¶added inv1.8.0
func (a *AutoEncryptionOptions) SetTLSConfig(tlsOpts map[string]*tls.Config) *AutoEncryptionOptions
SetTLSConfig specifies tls.Config instances for each KMS provider to use to configure TLS on all connections createdto the KMS provider.
This should only be used to set custom TLS configurations. By default, the connection will use an empty tls.Config{} with MinVersion set to tls.VersionTLS12.
typeBSONOptions¶added inv1.12.0
type BSONOptions struct {// UseJSONStructTags causes the driver to fall back to using the "json"// struct tag if a "bson" struct tag is not specified.UseJSONStructTagsbool// ErrorOnInlineDuplicates causes the driver to return an error if there is// a duplicate field in the marshaled BSON when the "inline" struct tag// option is set.ErrorOnInlineDuplicatesbool// IntMinSize causes the driver to marshal Go integer values (int, int8,// int16, int32, int64, uint, uint8, uint16, uint32, or uint64) as the// minimum BSON int size (either 32 or 64 bits) that can represent the// integer value.IntMinSizebool// NilMapAsEmpty causes the driver to marshal nil Go maps as empty BSON// documents instead of BSON null.//// Empty BSON documents take up slightly more space than BSON null, but// preserve the ability to use document update operations like "$set" that// do not work on BSON null.NilMapAsEmptybool// NilSliceAsEmpty causes the driver to marshal nil Go slices as empty BSON// arrays instead of BSON null.//// Empty BSON arrays take up slightly more space than BSON null, but// preserve the ability to use array update operations like "$push" or// "$addToSet" that do not work on BSON null.NilSliceAsEmptybool// NilByteSliceAsEmpty causes the driver to marshal nil Go byte slices as// empty BSON binary values instead of BSON null.NilByteSliceAsEmptybool// OmitZeroStruct causes the driver to consider the zero value for a struct// (e.g. MyStruct{}) as empty and omit it from the marshaled BSON when the// "omitempty" struct tag option is set.OmitZeroStructbool// StringifyMapKeysWithFmt causes the driver to convert Go map keys to BSON// document field name strings using fmt.Sprint instead of the default// string conversion logic.StringifyMapKeysWithFmtbool// AllowTruncatingDoubles causes the driver to truncate the fractional part// of BSON "double" values when attempting to unmarshal them into a Go// integer (int, int8, int16, int32, or int64) struct field. The truncation// logic does not apply to BSON "decimal128" values.AllowTruncatingDoublesbool// BinaryAsSlice causes the driver to unmarshal BSON binary field values// that are the "Generic" or "Old" BSON binary subtype as a Go byte slice// instead of a primitive.Binary.BinaryAsSlicebool// DefaultDocumentD causes the driver to always unmarshal documents into the// primitive.D type. This behavior is restricted to data typed as// "interface{}" or "map[string]interface{}".DefaultDocumentDbool// DefaultDocumentM causes the driver to always unmarshal documents into the// primitive.M type. This behavior is restricted to data typed as// "interface{}" or "map[string]interface{}".DefaultDocumentMbool// UseLocalTimeZone causes the driver to unmarshal time.Time values in the// local timezone instead of the UTC timezone.UseLocalTimeZonebool// ZeroMaps causes the driver to delete any existing values from Go maps in// the destination value before unmarshaling BSON documents into them.ZeroMapsbool// ZeroStructs causes the driver to delete any existing values from Go// structs in the destination value before unmarshaling BSON documents into// them.ZeroStructsbool}BSONOptions are optional BSON marshaling and unmarshaling behaviors.
typeBucketOptions¶added inv0.1.0
type BucketOptions struct {// The name of the bucket. The default value is "fs".Name *string// The number of bytes in each chunk in the bucket. The default value is 255 KiB.ChunkSizeBytes *int32// The write concern for the bucket. The default value is the write concern of the database from which the bucket// is created.WriteConcern *writeconcern.WriteConcern// The read concern for the bucket. The default value is the read concern of the database from which the bucket// is created.ReadConcern *readconcern.ReadConcern// The read preference for the bucket. The default value is the read preference of the database from which the// bucket is created.ReadPreference *readpref.ReadPref}BucketOptions represents options that can be used to configure GridFS bucket.
funcGridFSBucket¶added inv0.1.0
func GridFSBucket() *BucketOptions
GridFSBucket creates a new BucketOptions instance.
funcMergeBucketOptionsdeprecatedadded inv0.1.0
func MergeBucketOptions(opts ...*BucketOptions) *BucketOptions
MergeBucketOptions combines the given BucketOptions instances into a single BucketOptions in a last-one-wins fashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create asingle options struct instead.
func (*BucketOptions)SetChunkSizeBytes¶added inv0.1.0
func (b *BucketOptions) SetChunkSizeBytes(iint32) *BucketOptions
SetChunkSizeBytes sets the value for the ChunkSize field.
func (*BucketOptions)SetName¶added inv0.1.0
func (b *BucketOptions) SetName(namestring) *BucketOptions
SetName sets the value for the Name field.
func (*BucketOptions)SetReadConcern¶added inv0.1.0
func (b *BucketOptions) SetReadConcern(rc *readconcern.ReadConcern) *BucketOptions
SetReadConcern sets the value for the ReadConcern field.
func (*BucketOptions)SetReadPreference¶added inv0.1.0
func (b *BucketOptions) SetReadPreference(rp *readpref.ReadPref) *BucketOptions
SetReadPreference sets the value for the ReadPreference field.
func (*BucketOptions)SetWriteConcern¶added inv0.1.0
func (b *BucketOptions) SetWriteConcern(wc *writeconcern.WriteConcern) *BucketOptions
SetWriteConcern sets the value for the WriteConcern field.
typeBulkWriteOptions¶added inv0.1.0
type BulkWriteOptions struct {// If true, writes executed as part of the operation will opt out of document-level validation on the server. This// option is valid for MongoDB versions >= 3.2 and is ignored for previous server versions. The default value is// false. Seehttps://www.mongodb.com/docs/manual/core/schema-validation/ for more information about document// validation.BypassDocumentValidation *bool// A string or document that will be included in server logs, profiling logs, and currentOp queries to help trace// the operation. The default value is nil, which means that no comment will be included in the logs.Comment interface{}// If true, no writes will be executed after one fails. The default value is true.Ordered *bool// Specifies parameters for all update and delete commands in the BulkWrite. This option is only valid for MongoDB// versions >= 5.0. Older servers will report an error for using this option. This must be a document mapping// parameter names to values. Values must be constant or closed expressions that do not reference document fields.// Parameters can then be accessed as variables in an aggregate expression context (e.g. "$$var").Let interface{}// If true, the server accepts empty Timestamp as a literal rather than replacing it with the current time.//// Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any// release.BypassEmptyTsReplacement *bool}BulkWriteOptions represents options that can be used to configure a BulkWrite operation.
funcBulkWrite¶added inv0.1.0
func BulkWrite() *BulkWriteOptions
BulkWrite creates a new *BulkWriteOptions instance.
funcMergeBulkWriteOptionsdeprecatedadded inv0.1.0
func MergeBulkWriteOptions(opts ...*BulkWriteOptions) *BulkWriteOptions
MergeBulkWriteOptions combines the given BulkWriteOptions instances into a single BulkWriteOptions in a last-one-winsfashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create asingle options struct instead.
func (*BulkWriteOptions)SetBypassDocumentValidation¶added inv0.1.0
func (b *BulkWriteOptions) SetBypassDocumentValidation(bypassbool) *BulkWriteOptions
SetBypassDocumentValidation sets the value for the BypassDocumentValidation field.
func (*BulkWriteOptions)SetComment¶added inv1.10.0
func (b *BulkWriteOptions) SetComment(comment interface{}) *BulkWriteOptions
SetComment sets the value for the Comment field.
func (*BulkWriteOptions)SetLet¶added inv1.9.0
func (b *BulkWriteOptions) SetLet(let interface{}) *BulkWriteOptions
SetLet sets the value for the Let field. Let specifies parameters for all update and delete commands in the BulkWrite.This option is only valid for MongoDB versions >= 5.0. Older servers will report an error for using this option.This must be a document mapping parameter names to values. Values must be constant or closed expressions that do notreference document fields. Parameters can then be accessed as variables in an aggregate expression context (e.g. "$$var").
func (*BulkWriteOptions)SetOrdered¶added inv0.1.0
func (b *BulkWriteOptions) SetOrdered(orderedbool) *BulkWriteOptions
SetOrdered sets the value for the Ordered field.
typeChangeStreamOptions¶added inv0.1.0
type ChangeStreamOptions struct {// The maximum number of documents to be included in each batch returned by the server.BatchSize *int32// Specifies a collation to use for string comparisons during the operation. This option is only valid for MongoDB// versions >= 3.4. For previous server versions, the driver will return an error if this option is used. The// default value is nil, which means the default collation of the collection will be used.Collation *Collation// A string that will be included in server logs, profiling logs, and currentOp queries to help trace the operation.// The default is nil, which means that no comment will be included in the logs.Comment *string// Specifies how the updated document should be returned in change notifications for update operations. The default// is options.Default, which means that only partial update deltas will be included in the change notification.FullDocument *FullDocument// Specifies how the pre-update document should be returned in change notifications for update operations. The default// is options.Off, which means that the pre-update document will not be included in the change notification.FullDocumentBeforeChange *FullDocument// The maximum amount of time that the server should wait for new documents to satisfy a tailable cursor query.MaxAwaitTime *time.Duration// A document specifying the logical starting point for the change stream. Only changes corresponding to an oplog// entry immediately after the resume token will be returned. If this is specified, StartAtOperationTime and// StartAfter must not be set.ResumeAfter interface{}// ShowExpandedEvents specifies whether the server will return an expanded list of change stream events. Additional// events include: createIndexes, dropIndexes, modify, create, shardCollection, reshardCollection and// refineCollectionShardKey. This option is only valid for MongoDB versions >= 6.0.ShowExpandedEvents *bool// If specified, the change stream will only return changes that occurred at or after the given timestamp. This// option is only valid for MongoDB versions >= 4.0. If this is specified, ResumeAfter and StartAfter must not be// set.StartAtOperationTime *primitive.Timestamp// A document specifying the logical starting point for the change stream. This is similar to the ResumeAfter// option, but allows a resume token from an "invalidate" notification to be used. This allows a change stream on a// collection to be resumed after the collection has been dropped and recreated or renamed. Only changes// corresponding to an oplog entry immediately after the specified token will be returned. If this is specified,// ResumeAfter and StartAtOperationTime must not be set. This option is only valid for MongoDB versions >= 4.1.1.StartAfter interface{}// Custom options to be added to the initial aggregate for the change stream. Key-value pairs of the BSON map should// correlate with desired option names and values. Values must be Marshalable. Custom options may conflict with// non-custom options, and custom options bypass client-side validation. Prefer using non-custom options where possible.Custombson.M// Custom options to be added to the $changeStream stage in the initial aggregate. Key-value pairs of the BSON map should// correlate with desired option names and values. Values must be Marshalable. Custom pipeline options bypass client-side// validation. Prefer using non-custom options where possible.CustomPipelinebson.M}ChangeStreamOptions represents options that can be used to configure a Watch operation.
funcChangeStream¶added inv0.1.0
func ChangeStream() *ChangeStreamOptions
ChangeStream creates a new ChangeStreamOptions instance.
funcMergeChangeStreamOptionsdeprecatedadded inv0.1.0
func MergeChangeStreamOptions(opts ...*ChangeStreamOptions) *ChangeStreamOptions
MergeChangeStreamOptions combines the given ChangeStreamOptions instances into a single ChangeStreamOptions in alast-one-wins fashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create asingle options struct instead.
func (*ChangeStreamOptions)SetBatchSize¶added inv0.1.0
func (cso *ChangeStreamOptions) SetBatchSize(iint32) *ChangeStreamOptions
SetBatchSize sets the value for the BatchSize field.
func (*ChangeStreamOptions)SetCollation¶added inv0.1.0
func (cso *ChangeStreamOptions) SetCollation(cCollation) *ChangeStreamOptions
SetCollation sets the value for the Collation field.
func (*ChangeStreamOptions)SetComment¶added inv1.10.0
func (cso *ChangeStreamOptions) SetComment(commentstring) *ChangeStreamOptions
SetComment sets the value for the Comment field.
func (*ChangeStreamOptions)SetCustom¶added inv1.9.0
func (cso *ChangeStreamOptions) SetCustom(cbson.M) *ChangeStreamOptions
SetCustom sets the value for the Custom field. Key-value pairs of the BSON map should correlatewith desired option names and values. Values must be Marshalable. Custom options may conflictwith non-custom options, and custom options bypass client-side validation. Prefer using non-customoptions where possible.
func (*ChangeStreamOptions)SetCustomPipeline¶added inv1.9.0
func (cso *ChangeStreamOptions) SetCustomPipeline(cpbson.M) *ChangeStreamOptions
SetCustomPipeline sets the value for the CustomPipeline field. Key-value pairs of the BSON mapshould correlate with desired option names and values. Values must be Marshalable. Custom pipelineoptions bypass client-side validation. Prefer using non-custom options where possible.
func (*ChangeStreamOptions)SetFullDocument¶added inv0.1.0
func (cso *ChangeStreamOptions) SetFullDocument(fdFullDocument) *ChangeStreamOptions
SetFullDocument sets the value for the FullDocument field.
func (*ChangeStreamOptions)SetFullDocumentBeforeChange¶added inv1.10.0
func (cso *ChangeStreamOptions) SetFullDocumentBeforeChange(fdbcFullDocument) *ChangeStreamOptions
SetFullDocumentBeforeChange sets the value for the FullDocumentBeforeChange field.
func (*ChangeStreamOptions)SetMaxAwaitTime¶added inv0.1.0
func (cso *ChangeStreamOptions) SetMaxAwaitTime(dtime.Duration) *ChangeStreamOptions
SetMaxAwaitTime sets the value for the MaxAwaitTime field.
func (*ChangeStreamOptions)SetResumeAfter¶added inv0.1.0
func (cso *ChangeStreamOptions) SetResumeAfter(rt interface{}) *ChangeStreamOptions
SetResumeAfter sets the value for the ResumeAfter field.
func (*ChangeStreamOptions)SetShowExpandedEvents¶added inv1.10.0
func (cso *ChangeStreamOptions) SetShowExpandedEvents(seebool) *ChangeStreamOptions
SetShowExpandedEvents sets the value for the ShowExpandedEvents field.
func (*ChangeStreamOptions)SetStartAfter¶added inv1.1.0
func (cso *ChangeStreamOptions) SetStartAfter(sa interface{}) *ChangeStreamOptions
SetStartAfter sets the value for the StartAfter field.
func (*ChangeStreamOptions)SetStartAtOperationTime¶added inv0.1.0
func (cso *ChangeStreamOptions) SetStartAtOperationTime(t *primitive.Timestamp) *ChangeStreamOptions
SetStartAtOperationTime sets the value for the StartAtOperationTime field.
typeClientEncryptionOptions¶added inv1.2.0
type ClientEncryptionOptions struct {KeyVaultNamespacestringKmsProviders map[string]map[string]interface{}TLSConfig map[string]*tls.ConfigHTTPClient *http.Client}ClientEncryptionOptions represents all possible options used to configure a ClientEncryption instance.
funcClientEncryption¶added inv1.2.0
func ClientEncryption() *ClientEncryptionOptions
ClientEncryption creates a new ClientEncryptionOptions instance.
funcMergeClientEncryptionOptionsdeprecatedadded inv1.2.0
func MergeClientEncryptionOptions(opts ...*ClientEncryptionOptions) *ClientEncryptionOptions
MergeClientEncryptionOptions combines the argued ClientEncryptionOptions in a last-one wins fashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create asingle options struct instead.
func (*ClientEncryptionOptions)SetKeyVaultNamespace¶added inv1.2.0
func (c *ClientEncryptionOptions) SetKeyVaultNamespace(nsstring) *ClientEncryptionOptions
SetKeyVaultNamespace specifies the namespace of the key vault collection. This is required.
func (*ClientEncryptionOptions)SetKmsProviders¶added inv1.2.0
func (c *ClientEncryptionOptions) SetKmsProviders(providers map[string]map[string]interface{}) *ClientEncryptionOptions
SetKmsProviders specifies options for KMS providers. This is required.
func (*ClientEncryptionOptions)SetTLSConfig¶added inv1.8.0
func (c *ClientEncryptionOptions) SetTLSConfig(tlsOpts map[string]*tls.Config) *ClientEncryptionOptions
SetTLSConfig specifies tls.Config instances for each KMS provider to use to configure TLS on all connections createdto the KMS provider.
This should only be used to set custom TLS configurations. By default, the connection will use an empty tls.Config{} with MinVersion set to tls.VersionTLS12.
typeClientOptions¶added inv0.1.0
type ClientOptions struct {AppName *stringAuth *CredentialAutoEncryptionOptions *AutoEncryptionOptionsConnectTimeout *time.DurationCompressors []stringDialerContextDialerDirect *boolDisableOCSPEndpointCheck *boolHeartbeatInterval *time.DurationHosts []stringHTTPClient *http.ClientLoadBalanced *boolLocalThreshold *time.DurationLoggerOptions *LoggerOptionsMaxConnIdleTime *time.DurationMaxPoolSize *uint64MinPoolSize *uint64MaxConnecting *uint64PoolMonitor *event.PoolMonitorMonitor *event.CommandMonitorServerMonitor *event.ServerMonitorReadConcern *readconcern.ReadConcernReadPreference *readpref.ReadPrefBSONOptions *BSONOptionsRegistry *bsoncodec.RegistryReplicaSet *stringRetryReads *boolRetryWrites *boolServerAPIOptions *ServerAPIOptionsServerMonitoringMode *stringServerSelectionTimeout *time.DurationSRVMaxHosts *intSRVServiceName *stringTimeout *time.DurationTLSConfig *tls.ConfigWriteConcern *writeconcern.WriteConcernZlibLevel *intZstdLevel *int// AuthenticateToAnything skips server type checks when deciding if authentication is possible.//// Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any// release.AuthenticateToAnything *bool// Crypt specifies a custom driver.Crypt to be used to encrypt and decrypt documents. The default is no// encryption.//// Deprecated: This option is for internal use only and should not be set (see GODRIVER-2149). It may be// changed or removed in any release.Cryptdriver.Crypt// Deployment specifies a custom deployment to use for the new Client.//// Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any// release.Deploymentdriver.Deployment// SocketTimeout specifies the timeout to be used for the Client's socket reads and writes.//// NOTE(benjirewis): SocketTimeout will be deprecated in a future release. The more general Timeout option// may be used in its place to control the amount of time that a single operation can run before returning// an error. Setting SocketTimeout and Timeout on a single client will result in undefined behavior.SocketTimeout *time.Duration// contains filtered or unexported fields}ClientOptions contains options to configure a Client instance. Each option can be set through setter functions. Seedocumentation for each setter function for an explanation of the option.
funcMergeClientOptionsdeprecatedadded inv0.1.0
func MergeClientOptions(opts ...*ClientOptions) *ClientOptions
MergeClientOptions combines the given *ClientOptions into a single *ClientOptions in a last one wins fashion.The specified options are merged with the existing options on the client, with the specified options takingprecedence.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create asingle options struct instead.
func (*ClientOptions)ApplyURI¶added inv1.0.0
func (c *ClientOptions) ApplyURI(uristring) *ClientOptions
ApplyURI parses the given URI and sets options accordingly. The URI can contain host names, IPv4/IPv6 literals, oran SRV record that will be resolved when the Client is created. When using an SRV record, TLS support isimplicitly enabled. Specify the "tls=false" URI option to override this.
If the connection string contains any options that have previously been set, it will overwrite them. Options thatcorrespond to multiple URI parameters, such as WriteConcern, will be completely overwritten if any of the queryparameters are specified. If an option is set on ClientOptions after this method is called, that option will overrideany option applied via the connection string.
If the URI format is incorrect or there are conflicting options specified in the URI an error will be recorded andcan be retrieved by calling Validate.
For more information about the URI format, seehttps://www.mongodb.com/docs/manual/reference/connection-string/. Seemongo.Connect documentation for examples of using URIs for different Client configurations.
func (*ClientOptions)GetURI¶added inv1.3.1
func (c *ClientOptions) GetURI()string
GetURI returns the original URI used to configure the ClientOptions instance. If ApplyURI was not called duringconstruction, this returns "".
func (*ClientOptions)SetAppName¶added inv0.1.0
func (c *ClientOptions) SetAppName(sstring) *ClientOptions
SetAppName specifies an application name that is sent to the server when creating new connections. It is used by theserver to log connection and profiling information (e.g. slow query logs). This can also be set through the "appName"URI option (e.g "appName=example_application"). The default is empty, meaning no app name will be sent.
func (*ClientOptions)SetAuth¶added inv0.1.0
func (c *ClientOptions) SetAuth(authCredential) *ClientOptions
SetAuth specifies a Credential containing options for configuring authentication. See the options.Credentialdocumentation for more information about Credential fields. The default is an empty Credential, meaning noauthentication will be configured.
func (*ClientOptions)SetAutoEncryptionOptions¶added inv1.2.0
func (c *ClientOptions) SetAutoEncryptionOptions(opts *AutoEncryptionOptions) *ClientOptions
SetAutoEncryptionOptions specifies an AutoEncryptionOptions instance to automatically encrypt and decrypt commandsand their results. See the options.AutoEncryptionOptions documentation for more information about the supportedoptions.
func (*ClientOptions)SetBSONOptions¶added inv1.12.0
func (c *ClientOptions) SetBSONOptions(opts *BSONOptions) *ClientOptions
SetBSONOptions configures optional BSON marshaling and unmarshaling behavior.
func (*ClientOptions)SetCompressors¶added inv1.0.0
func (c *ClientOptions) SetCompressors(comps []string) *ClientOptions
SetCompressors sets the compressors that can be used when communicating with a server. Valid values are:
1. "snappy" - requires server version >= 3.4
2. "zlib" - requires server version >= 3.6
3. "zstd" - requires server version >= 4.2, and driver version >= 1.2.0 with cgo support enabled or driverversion >= 1.3.0 without cgo.
If this option is specified, the driver will perform a negotiation with the server to determine a common list ofcompressors and will use the first one in that list when performing operations. Seehttps://www.mongodb.com/docs/manual/reference/program/mongod/#cmdoption-mongod-networkmessagecompressors for moreinformation about configuring compression on the server and the server-side defaults.
This can also be set through the "compressors" URI option (e.g. "compressors=zstd,zlib,snappy"). The default isan empty slice, meaning no compression will be enabled.
func (*ClientOptions)SetConnectTimeout¶added inv0.1.0
func (c *ClientOptions) SetConnectTimeout(dtime.Duration) *ClientOptions
SetConnectTimeout specifies a timeout that is used for creating connections to the server. This can be set throughApplyURI with the "connectTimeoutMS" (e.g "connectTimeoutMS=30") option. If set to 0, no timeout will be used. Thedefault is 30 seconds.
func (*ClientOptions)SetDialer¶added inv0.1.0
func (c *ClientOptions) SetDialer(dContextDialer) *ClientOptions
SetDialer specifies a custom ContextDialer to be used to create new connections to the server. This method overridesthe default net.Dialer, so dialer options such as Timeout, KeepAlive, Resolver, etc can be set.Seehttps://golang.org/pkg/net/#Dialer for more information about the net.Dialer type.
func (*ClientOptions)SetDirect¶added inv1.0.0
func (c *ClientOptions) SetDirect(bbool) *ClientOptions
SetDirect specifies whether or not a direct connect should be made. If set to true, the driver will only connect tothe host provided in the URI and will not discover other hosts in the cluster. This can also be set through the"directConnection" URI option. This option cannot be set to true if multiple hosts are specified, either throughApplyURI or SetHosts, or an SRV URI is used.
As of driver version 1.4, the "connect" URI option has been deprecated and replaced with "directConnection". The"connect" URI option has two values:
1. "connect=direct" for direct connections. This corresponds to "directConnection=true".
2. "connect=automatic" for automatic discovery. This corresponds to "directConnection=false"
If the "connect" and "directConnection" URI options are both specified in the connection string, their values mustnot conflict. Direct connections are not valid if multiple hosts are specified or an SRV URI is used. The defaultvalue for this option is false.
func (*ClientOptions)SetDisableOCSPEndpointCheck¶added inv1.4.0
func (c *ClientOptions) SetDisableOCSPEndpointCheck(disableCheckbool) *ClientOptions
SetDisableOCSPEndpointCheck specifies whether or not the driver should reach out to OCSP responders to verify thecertificate status for certificates presented by the server that contain a list of OCSP responders.
If set to true, the driver will verify the status of the certificate using a response stapled by the server, if thereis one, but will not send an HTTP request to any responders if there is no staple. In this case, the driver willcontinue the connection even though the certificate status is not known.
This can also be set through the tlsDisableOCSPEndpointCheck URI option. Both this URI option and tlsInsecure mustnot be set at the same time and will error if they are. The default value is false.
func (*ClientOptions)SetHTTPClient¶added inv1.11.0
func (c *ClientOptions) SetHTTPClient(client *http.Client) *ClientOptions
SetHTTPClient specifies the http.Client to be used for any HTTP requests.
This should only be used to set custom HTTP client configurations. By default, the connection will use an httputil.DefaultHTTPClient.
func (*ClientOptions)SetHeartbeatInterval¶added inv0.1.0
func (c *ClientOptions) SetHeartbeatInterval(dtime.Duration) *ClientOptions
SetHeartbeatInterval specifies the amount of time to wait between periodic background server checks. This can also beset through the "heartbeatIntervalMS" URI option (e.g. "heartbeatIntervalMS=10000"). The default is 10 seconds.
func (*ClientOptions)SetHosts¶added inv0.1.0
func (c *ClientOptions) SetHosts(s []string) *ClientOptions
SetHosts specifies a list of host names or IP addresses for servers in a cluster. Both IPv4 and IPv6 addresses aresupported. IPv6 literals must be enclosed in '[]' following RFC-2732 syntax.
Hosts can also be specified as a comma-separated list in a URI. For example, to include "localhost:27017" and"localhost:27018", a URI could be "mongodb://localhost:27017,localhost:27018". The default is ["localhost:27017"]
func (*ClientOptions)SetLoadBalanced¶added inv1.6.0
func (c *ClientOptions) SetLoadBalanced(lbbool) *ClientOptions
SetLoadBalanced specifies whether or not the MongoDB deployment is hosted behind a load balancer. This can also beset through the "loadBalanced" URI option. The driver will error during Client configuration if this option is setto true and one of the following conditions are met:
1. Multiple hosts are specified, either via the ApplyURI or SetHosts methods. This includes the case where an SRVURI is used and the SRV record resolves to multiple hostnames.2. A replica set name is specified, either via the URI or the SetReplicaSet method.3. The options specify whether or not a direct connection should be made, either via the URI or the SetDirect method.
The default value is false.
func (*ClientOptions)SetLocalThreshold¶added inv0.1.0
func (c *ClientOptions) SetLocalThreshold(dtime.Duration) *ClientOptions
SetLocalThreshold specifies the width of the 'latency window': when choosing between multiple suitable servers for anoperation, this is the acceptable non-negative delta between shortest and longest average round-trip times. A serverwithin the latency window is selected randomly. This can also be set through the "localThresholdMS" URI option (e.g."localThresholdMS=15000"). The default is 15 milliseconds.
func (*ClientOptions)SetLoggerOptions¶added inv1.12.0
func (c *ClientOptions) SetLoggerOptions(opts *LoggerOptions) *ClientOptions
SetLoggerOptions specifies a LoggerOptions containing options forconfiguring a logger.
Example (CustomLogger)¶
package mainimport ("bytes""context""fmt""io""log""sync""go.mongodb.org/mongo-driver/mongo""go.mongodb.org/mongo-driver/mongo/options")type CustomLogger struct {io.Writermu sync.Mutex}func (logger *CustomLogger) Info(level int, msg string, _ ...interface{}) {logger.mu.Lock()defer logger.mu.Unlock()fmt.Fprintf(logger, "level=%d msg=%s\n", level, msg)}func (logger *CustomLogger) Error(err error, msg string, _ ...interface{}) {logger.mu.Lock()defer logger.mu.Unlock()fmt.Fprintf(logger, "err=%v msg=%s\n", err, msg)}func main() {buf := bytes.NewBuffer(nil)sink := &CustomLogger{Writer: buf}// Create a client with our logger options.loggerOptions := options.Logger().SetSink(sink).SetMaxDocumentLength(25).SetComponentLevel(options.LogComponentCommand, options.LogLevelDebug)clientOptions := options.Client().ApplyURI("mongodb://localhost:27017").SetLoggerOptions(loggerOptions)client, err := mongo.Connect(context.TODO(), clientOptions)if err != nil {log.Panicf("error connecting to MongoDB: %v", err)}defer func() { _ = client.Disconnect(context.TODO()) }()// Make a database request to test our logging solution.coll := client.Database("test").Collection("test")_, err = coll.InsertOne(context.TODO(), map[string]string{"foo": "bar"})if err != nil {log.Panicf("InsertOne failed: %v", err)}// Print the logs.fmt.Println(buf.String())}func (*ClientOptions)SetMaxConnIdleTime¶added inv0.1.0
func (c *ClientOptions) SetMaxConnIdleTime(dtime.Duration) *ClientOptions
SetMaxConnIdleTime specifies the maximum amount of time that a connection will remain idle in a connection poolbefore it is removed from the pool and closed. This can also be set through the "maxIdleTimeMS" URI option (e.g."maxIdleTimeMS=10000"). The default is 0, meaning a connection can remain unused indefinitely.
func (*ClientOptions)SetMaxConnecting¶added inv1.8.2
func (c *ClientOptions) SetMaxConnecting(uuint64) *ClientOptions
SetMaxConnecting specifies the maximum number of connections a connection pool may establish simultaneously. This canalso be set through the "maxConnecting" URI option (e.g. "maxConnecting=2"). If this is 0, the default is used. Thedefault is 2. Values greater than 100 are not recommended.
func (*ClientOptions)SetMaxPoolSize¶added inv0.1.0
func (c *ClientOptions) SetMaxPoolSize(uuint64) *ClientOptions
SetMaxPoolSize specifies that maximum number of connections allowed in the driver's connection pool to each server.Requests to a server will block if this maximum is reached. This can also be set through the "maxPoolSize" URI option(e.g. "maxPoolSize=100"). If this is 0, maximum connection pool size is not limited. The default is 100.
func (*ClientOptions)SetMinPoolSize¶added inv1.1.0
func (c *ClientOptions) SetMinPoolSize(uuint64) *ClientOptions
SetMinPoolSize specifies the minimum number of connections allowed in the driver's connection pool to each server. Ifthis is non-zero, each server's pool will be maintained in the background to ensure that the size does not fall belowthe minimum. This can also be set through the "minPoolSize" URI option (e.g. "minPoolSize=100"). The default is 0.
func (*ClientOptions)SetMonitor¶added inv0.1.0
func (c *ClientOptions) SetMonitor(m *event.CommandMonitor) *ClientOptions
SetMonitor specifies a CommandMonitor to receive command events. See the event.CommandMonitor documentation for moreinformation about the structure of the monitor and events that can be received.
func (*ClientOptions)SetPoolMonitor¶added inv1.1.0
func (c *ClientOptions) SetPoolMonitor(m *event.PoolMonitor) *ClientOptions
SetPoolMonitor specifies a PoolMonitor to receive connection pool events. See the event.PoolMonitor documentationfor more information about the structure of the monitor and events that can be received.
func (*ClientOptions)SetReadConcern¶added inv0.1.0
func (c *ClientOptions) SetReadConcern(rc *readconcern.ReadConcern) *ClientOptions
SetReadConcern specifies the read concern to use for read operations. A read concern level can also be set throughthe "readConcernLevel" URI option (e.g. "readConcernLevel=majority"). The default is nil, meaning the server will useits configured default.
func (*ClientOptions)SetReadPreference¶added inv0.1.0
func (c *ClientOptions) SetReadPreference(rp *readpref.ReadPref) *ClientOptions
SetReadPreference specifies the read preference to use for read operations. This can also be set through thefollowing URI options:
1. "readPreference" - Specify the read preference mode (e.g. "readPreference=primary").
2. "readPreferenceTags": Specify one or more read preference tags(e.g. "readPreferenceTags=region:south,datacenter:A").
3. "maxStalenessSeconds" (or "maxStaleness"): Specify a maximum replication lag for reads from secondaries in areplica set (e.g. "maxStalenessSeconds=10").
The default is readpref.Primary(). Seehttps://www.mongodb.com/docs/manual/core/read-preference/#read-preference formore information about read preferences.
func (*ClientOptions)SetRegistry¶added inv0.1.0
func (c *ClientOptions) SetRegistry(registry *bsoncodec.Registry) *ClientOptions
SetRegistry specifies the BSON registry to use for BSON marshalling/unmarshalling operations. The default isbson.DefaultRegistry.
func (*ClientOptions)SetReplicaSet¶added inv0.1.0
func (c *ClientOptions) SetReplicaSet(sstring) *ClientOptions
SetReplicaSet specifies the replica set name for the cluster. If specified, the cluster will be treated as a replicaset and the driver will automatically discover all servers in the set, starting with the nodes specified throughApplyURI or SetHosts. All nodes in the replica set must have the same replica set name, or they will not beconsidered as part of the set by the Client. This can also be set through the "replicaSet" URI option (e.g."replicaSet=replset"). The default is empty.
func (*ClientOptions)SetRetryReads¶added inv1.2.0
func (c *ClientOptions) SetRetryReads(bbool) *ClientOptions
SetRetryReads specifies whether supported read operations should be retried once on certain errors, such as networkerrors.
Supported operations are Find, FindOne, Aggregate without a $out stage, Distinct, CountDocuments,EstimatedDocumentCount, Watch (for Client, Database, and Collection), ListCollections, and ListDatabases. Note thatoperations run through RunCommand are not retried.
This option requires server version >= 3.6 and driver version >= 1.1.0. The default is true.
func (*ClientOptions)SetRetryWrites¶added inv0.1.0
func (c *ClientOptions) SetRetryWrites(bbool) *ClientOptions
SetRetryWrites specifies whether supported write operations should be retried once on certain errors, such as networkerrors.
Supported operations are InsertOne, UpdateOne, ReplaceOne, DeleteOne, FindOneAndDelete, FindOneAndReplace,FindOneAndDelete, InsertMany, and BulkWrite. Note that BulkWrite requests must not include UpdateManyModel orDeleteManyModel instances to be considered retryable. Unacknowledged writes will not be retried, even if this optionis set to true.
This option requires server version >= 3.6 and a replica set or sharded cluster and will be ignored for any othercluster type. This can also be set through the "retryWrites" URI option (e.g. "retryWrites=true"). The default istrue.
func (*ClientOptions)SetSRVMaxHosts¶added inv1.8.0
func (c *ClientOptions) SetSRVMaxHosts(srvMaxHostsint) *ClientOptions
SetSRVMaxHosts specifies the maximum number of SRV results to randomly select during polling. To limit the numberof hosts selected in SRV discovery, this function must be called before ApplyURI. This can also be set throughthe "srvMaxHosts" URI option.
func (*ClientOptions)SetSRVServiceName¶added inv1.8.0
func (c *ClientOptions) SetSRVServiceName(srvNamestring) *ClientOptions
SetSRVServiceName specifies a custom SRV service name to use in SRV polling. To use a custom SRV service namein SRV discovery, this function must be called before ApplyURI. This can also be set through the "srvServiceName"URI option.
func (*ClientOptions)SetServerAPIOptions¶added inv1.6.0
func (c *ClientOptions) SetServerAPIOptions(opts *ServerAPIOptions) *ClientOptions
SetServerAPIOptions specifies a ServerAPIOptions instance used to configure the API version sent to the serverwhen running commands. See the options.ServerAPIOptions documentation for more information about the supportedoptions.
func (*ClientOptions)SetServerMonitor¶added inv1.5.0
func (c *ClientOptions) SetServerMonitor(m *event.ServerMonitor) *ClientOptions
SetServerMonitor specifies an SDAM monitor used to monitor SDAM events.
func (*ClientOptions)SetServerMonitoringMode¶added inv1.13.0
func (c *ClientOptions) SetServerMonitoringMode(modestring) *ClientOptions
SetServerMonitoringMode specifies the server monitoring protocol to use. Seethe helper constants ServerMonitoringModeAuto, ServerMonitoringModePoll, andServerMonitoringModeStream for more information about valid servermonitoring modes.
func (*ClientOptions)SetServerSelectionTimeout¶added inv0.1.0
func (c *ClientOptions) SetServerSelectionTimeout(dtime.Duration) *ClientOptions
SetServerSelectionTimeout specifies how long the driver will wait to find an available, suitable server to execute anoperation. This can also be set through the "serverSelectionTimeoutMS" URI option (e.g."serverSelectionTimeoutMS=30000"). The default value is 30 seconds.
func (*ClientOptions)SetSocketTimeout¶added inv0.1.0
func (c *ClientOptions) SetSocketTimeout(dtime.Duration) *ClientOptions
SetSocketTimeout specifies how long the driver will wait for a socket read or write to return before returning anetwork error. This can also be set through the "socketTimeoutMS" URI option (e.g. "socketTimeoutMS=1000"). Thedefault value is 0, meaning no timeout is used and socket operations can block indefinitely.
NOTE(benjirewis): SocketTimeout will be deprecated in a future release. The more general Timeout option may be usedin its place to control the amount of time that a single operation can run before returning an error. SettingSocketTimeout and Timeout on a single client will result in undefined behavior.
func (*ClientOptions)SetTLSConfig¶added inv1.0.0
func (c *ClientOptions) SetTLSConfig(cfg *tls.Config) *ClientOptions
SetTLSConfig specifies a tls.Config instance to use use to configure TLS on all connections created to the cluster.This can also be set through the following URI options:
1. "tls" (or "ssl"): Specify if TLS should be used (e.g. "tls=true").
2. Either "tlsCertificateKeyFile" (or "sslClientCertificateKeyFile") or a combination of "tlsCertificateFile" and"tlsPrivateKeyFile". The "tlsCertificateKeyFile" option specifies a path to the client certificate and private key,which must be concatenated into one file. The "tlsCertificateFile" and "tlsPrivateKey" combination specifies separatepaths to the client certificate and private key, respectively. Note that if "tlsCertificateKeyFile" is used, theother two options must not be specified. Only the subject name of the first certificate is honored as the usernamefor X509 auth in a file with multiple certs.
3. "tlsCertificateKeyFilePassword" (or "sslClientCertificateKeyPassword"): Specify the password to decrypt the clientprivate key file (e.g. "tlsCertificateKeyFilePassword=password").
4. "tlsCaFile" (or "sslCertificateAuthorityFile"): Specify the path to a single or bundle of certificate authoritiesto be considered trusted when making a TLS connection (e.g. "tlsCaFile=/path/to/caFile").
5. "tlsInsecure" (or "sslInsecure"): Specifies whether or not certificates and hostnames received from the servershould be validated. If true (e.g. "tlsInsecure=true"), the TLS library will accept any certificate presented by theserver and any host name in that certificate. Note that setting this to true makes TLS susceptible toman-in-the-middle attacks and should only be done for testing.
The default is nil, meaning no TLS will be enabled.
func (*ClientOptions)SetTimeout¶added inv1.10.0
func (c *ClientOptions) SetTimeout(dtime.Duration) *ClientOptions
SetTimeout specifies the amount of time that a single operation run on this Client can execute before returning an error.The deadline of any operation run through the Client will be honored above any Timeout set on the Client; Timeout will onlybe honored if there is no deadline on the operation Context. Timeout can also be set through the "timeoutMS" URI option(e.g. "timeoutMS=1000"). The default value is nil, meaning operations do not inherit a timeout from the Client.
If any Timeout is set (even 0) on the Client, the values of MaxTime on operation options, TransactionOptions.MaxCommitTime andSessionOptions.DefaultMaxCommitTime will be ignored. Setting Timeout and SocketTimeout or WriteConcern.wTimeout will resultin undefined behavior.
NOTE(benjirewis): SetTimeout represents unstable, provisional API. The behavior of the driver when a Timeout is specified issubject to change.
func (*ClientOptions)SetWriteConcern¶added inv0.1.0
func (c *ClientOptions) SetWriteConcern(wc *writeconcern.WriteConcern) *ClientOptions
SetWriteConcern specifies the write concern to use to for write operations. This can also be set through the followingURI options:
1. "w": Specify the number of nodes in the cluster that must acknowledge write operations before the operationreturns or "majority" to specify that a majority of the nodes must acknowledge writes. This can either be an integer(e.g. "w=10") or the string "majority" (e.g. "w=majority").
2. "wTimeoutMS": Specify how long write operations should wait for the correct number of nodes to acknowledge theoperation (e.g. "wTimeoutMS=1000").
3. "journal": Specifies whether or not write operations should be written to an on-disk journal on the server beforereturning (e.g. "journal=true").
The default is nil, meaning the server will use its configured default.
func (*ClientOptions)SetZlibLevel¶added inv1.0.0
func (c *ClientOptions) SetZlibLevel(levelint) *ClientOptions
SetZlibLevel specifies the level for the zlib compressor. This option is ignored if zlib is not specified as acompressor through ApplyURI or SetCompressors. Supported values are -1 through 9, inclusive. -1 tells the zliblibrary to use its default, 0 means no compression, 1 means best speed, and 9 means best compression.This can also be set through the "zlibCompressionLevel" URI option (e.g. "zlibCompressionLevel=-1"). Defaults to -1.
func (*ClientOptions)SetZstdLevel¶added inv1.2.0
func (c *ClientOptions) SetZstdLevel(levelint) *ClientOptions
SetZstdLevel sets the level for the zstd compressor. This option is ignored if zstd is not specified as a compressorthrough ApplyURI or SetCompressors. Supported values are 1 through 20, inclusive. 1 means best speed and 20 meansbest compression. This can also be set through the "zstdCompressionLevel" URI option. Defaults to 6.
func (*ClientOptions)Validate¶added inv1.0.0
func (c *ClientOptions) Validate()error
Validate validates the client options. This method will return the first error found.
typeCollation¶added inv0.1.0
type Collation struct {Localestring `bson:",omitempty"`// The localeCaseLevelbool `bson:",omitempty"`// The case levelCaseFirststring `bson:",omitempty"`// The case orderingStrengthint `bson:",omitempty"`// The number of comparison levels to useNumericOrderingbool `bson:",omitempty"`// Whether to order numbers based on numerical order and not collation orderAlternatestring `bson:",omitempty"`// Whether spaces and punctuation are considered base charactersMaxVariablestring `bson:",omitempty"`// Which characters are affected by alternate: "shifted"Normalizationbool `bson:",omitempty"`// Causes text to be normalized into Unicode NFDBackwardsbool `bson:",omitempty"`// Causes secondary differences to be considered in reverse order, as it is done in the French language}Collation allows users to specify language-specific rules for string comparison, such asrules for lettercase and accent marks.
func (*Collation)ToDocumentdeprecatedadded inv0.1.0
typeCollectionOptions¶added inv0.1.0
type CollectionOptions struct {// ReadConcern is the read concern to use for operations executed on the Collection. The default value is nil, which means that// the read concern of the Database used to configure the Collection will be used.ReadConcern *readconcern.ReadConcern// WriteConcern is the write concern to use for operations executed on the Collection. The default value is nil, which means that// the write concern of the Database used to configure the Collection will be used.WriteConcern *writeconcern.WriteConcern// ReadPreference is the read preference to use for operations executed on the Collection. The default value is nil, which means that// the read preference of the Database used to configure the Collection will be used.ReadPreference *readpref.ReadPref// BSONOptions configures optional BSON marshaling and unmarshaling// behavior.BSONOptions *BSONOptions// Registry is the BSON registry to marshal and unmarshal documents for operations executed on the Collection. The default value// is nil, which means that the registry of the Database used to configure the Collection will be used.Registry *bsoncodec.Registry}CollectionOptions represents options that can be used to configure a Collection.
funcCollection¶added inv0.1.0
func Collection() *CollectionOptions
Collection creates a new CollectionOptions instance.
funcMergeCollectionOptionsdeprecatedadded inv0.1.0
func MergeCollectionOptions(opts ...*CollectionOptions) *CollectionOptions
MergeCollectionOptions combines the given CollectionOptions instances into a single *CollectionOptions in alast-one-wins fashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create asingle options struct instead.
func (*CollectionOptions)SetBSONOptions¶added inv1.12.0
func (c *CollectionOptions) SetBSONOptions(opts *BSONOptions) *CollectionOptions
SetBSONOptions configures optional BSON marshaling and unmarshaling behavior.
func (*CollectionOptions)SetReadConcern¶added inv0.1.0
func (c *CollectionOptions) SetReadConcern(rc *readconcern.ReadConcern) *CollectionOptions
SetReadConcern sets the value for the ReadConcern field.
func (*CollectionOptions)SetReadPreference¶added inv0.1.0
func (c *CollectionOptions) SetReadPreference(rp *readpref.ReadPref) *CollectionOptions
SetReadPreference sets the value for the ReadPreference field.
func (*CollectionOptions)SetRegistry¶added inv0.1.0
func (c *CollectionOptions) SetRegistry(r *bsoncodec.Registry) *CollectionOptions
SetRegistry sets the value for the Registry field.
func (*CollectionOptions)SetWriteConcern¶added inv0.1.0
func (c *CollectionOptions) SetWriteConcern(wc *writeconcern.WriteConcern) *CollectionOptions
SetWriteConcern sets the value for the WriteConcern field.
typeContextDialer¶added inv0.1.0
type ContextDialer interface {DialContext(ctxcontext.Context, network, addressstring) (net.Conn,error)}ContextDialer is an interface that can be implemented by types that can create connections. It should be used toprovide a custom dialer when configuring a Client.
DialContext should return a connection to the provided address on the given network.
typeCountOptions¶added inv0.1.0
type CountOptions struct {// Specifies a collation to use for string comparisons during the operation. This option is only valid for MongoDB// versions >= 3.4. For previous server versions, the driver will return an error if this option is used. The// default value is nil, which means the default collation of the collection will be used.Collation *Collation// A string or document that will be included in server logs, profiling logs, and currentOp queries to help trace// the operation. The default is nil, which means that no comment will be included in the logs.Comment *string// The index to use for the aggregation. This should either be the index name as a string or the index specification// as a document. The driver will return an error if the hint parameter is a multi-key map. The default value is nil,// which means that no hint will be sent.Hint interface{}// The maximum number of documents to count. The default value is 0, which means that there is no limit and all// documents matching the filter will be counted.Limit *int64// The maximum amount of time that the query can run on the server. The default value is nil, meaning that there is// no time limit for query execution.//// NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeout option may be used in// its place to control the amount of time that a single operation can run before returning an error. MaxTime is// ignored if Timeout is set on the client.MaxTime *time.Duration// The number of documents to skip before counting. The default value is 0.Skip *int64}CountOptions represents options that can be used to configure a CountDocuments operation.
funcMergeCountOptionsdeprecatedadded inv0.1.0
func MergeCountOptions(opts ...*CountOptions) *CountOptions
MergeCountOptions combines the given CountOptions instances into a single CountOptions in a last-one-wins fashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create asingle options struct instead.
func (*CountOptions)SetCollation¶added inv0.1.0
func (co *CountOptions) SetCollation(c *Collation) *CountOptions
SetCollation sets the value for the Collation field.
func (*CountOptions)SetComment¶added inv1.10.0
func (co *CountOptions) SetComment(cstring) *CountOptions
SetComment sets the value for the Comment field.
func (*CountOptions)SetHint¶added inv0.1.0
func (co *CountOptions) SetHint(h interface{}) *CountOptions
SetHint sets the value for the Hint field.
func (*CountOptions)SetLimit¶added inv0.1.0
func (co *CountOptions) SetLimit(iint64) *CountOptions
SetLimit sets the value for the Limit field.
func (*CountOptions)SetMaxTime¶added inv0.1.0
func (co *CountOptions) SetMaxTime(dtime.Duration) *CountOptions
SetMaxTime sets the value for the MaxTime field.
NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeoutoption may be used in its place to control the amount of time that a single operation canrun before returning an error. MaxTime is ignored if Timeout is set on the client.
func (*CountOptions)SetSkip¶added inv0.1.0
func (co *CountOptions) SetSkip(iint64) *CountOptions
SetSkip sets the value for the Skip field.
typeCreateCollectionOptions¶added inv1.4.0
type CreateCollectionOptions struct {// Specifies if the collection is capped (seehttps://www.mongodb.com/docs/manual/core/capped-collections/). If true,// the SizeInBytes option must also be specified. The default value is false.Capped *bool// Specifies the default collation for the new collection. This option is only valid for MongoDB versions >= 3.4.// For previous server versions, the driver will return an error if this option is used. The default value is nil.Collation *Collation// Specifies how change streams opened against the collection can return pre- and post-images of updated// documents. The value must be a document in the form {<option name>: <options>}. This option is only valid for// MongoDB versions >= 6.0. The default value is nil, which means that change streams opened against the collection// will not return pre- and post-images of updated documents in any way.ChangeStreamPreAndPostImages interface{}// Specifies a default configuration for indexes on the collection. This option is only valid for MongoDB versions// >= 3.4. The default value is nil, meaning indexes will be configured using server defaults.DefaultIndexOptions *DefaultIndexOptions// Specifies the maximum number of documents allowed in a capped collection. The limit specified by the SizeInBytes// option takes precedence over this option. If a capped collection reaches its size limit, old documents will be// removed, regardless of the number of documents in the collection. The default value is 0, meaning the maximum// number of documents is unbounded.MaxDocuments *int64// Specifies the maximum size in bytes for a capped collection. The default value is 0.SizeInBytes *int64// Specifies the storage engine to use for the index. The value must be a document in the form// {<storage engine name>: <options>}. The default value is nil, which means that the default storage engine// will be used.StorageEngine interface{}// Specifies what should happen if a document being inserted does not pass validation. Valid values are "error" and// "warn". Seehttps://www.mongodb.com/docs/manual/core/schema-validation/#accept-or-reject-invalid-documents for more// information. This option is only valid for MongoDB versions >= 3.2. The default value is "error".ValidationAction *string// Specifies how strictly the server applies validation rules to existing documents in the collection during update// operations. Valid values are "off", "strict", and "moderate". See//https://www.mongodb.com/docs/manual/core/schema-validation/#existing-documents for more information. This option is// only valid for MongoDB versions >= 3.2. The default value is "strict".ValidationLevel *string// A document specifying validation rules for the collection. See//https://www.mongodb.com/docs/manual/core/schema-validation/ for more information about schema validation. This option// is only valid for MongoDB versions >= 3.2. The default value is nil, meaning no validator will be used for the// collection.Validator interface{}// Value indicating after how many seconds old time-series data should be deleted. See//https://www.mongodb.com/docs/manual/reference/command/create/ for supported options, and//https://www.mongodb.com/docs/manual/core/timeseries-collections/ for more information on time-series// collections.//// This option is only valid for MongoDB versions >= 5.0ExpireAfterSeconds *int64// Options for specifying a time-series collection. See//https://www.mongodb.com/docs/manual/reference/command/create/ for supported options, and//https://www.mongodb.com/docs/manual/core/timeseries-collections/ for more information on time-series// collections.//// This option is only valid for MongoDB versions >= 5.0TimeSeriesOptions *TimeSeriesOptions// EncryptedFields configures encrypted fields.//// This option is only valid for MongoDB versions >= 6.0EncryptedFields interface{}// ClusteredIndex is used to create a collection with a clustered index.//// This option is only valid for MongoDB versions >= 5.3ClusteredIndex interface{}}CreateCollectionOptions represents options that can be used to configure a CreateCollection operation.
funcCreateCollection¶added inv1.4.0
func CreateCollection() *CreateCollectionOptions
CreateCollection creates a new CreateCollectionOptions instance.
funcMergeCreateCollectionOptionsdeprecatedadded inv1.4.0
func MergeCreateCollectionOptions(opts ...*CreateCollectionOptions) *CreateCollectionOptions
MergeCreateCollectionOptions combines the given CreateCollectionOptions instances into a singleCreateCollectionOptions in a last-one-wins fashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create asingle options struct instead.
func (*CreateCollectionOptions)SetCapped¶added inv1.4.0
func (c *CreateCollectionOptions) SetCapped(cappedbool) *CreateCollectionOptions
SetCapped sets the value for the Capped field.
func (*CreateCollectionOptions)SetChangeStreamPreAndPostImages¶added inv1.10.0
func (c *CreateCollectionOptions) SetChangeStreamPreAndPostImages(csppi interface{}) *CreateCollectionOptions
SetChangeStreamPreAndPostImages sets the value for the ChangeStreamPreAndPostImages field.
func (*CreateCollectionOptions)SetClusteredIndex¶added inv1.10.0
func (c *CreateCollectionOptions) SetClusteredIndex(clusteredIndex interface{}) *CreateCollectionOptions
SetClusteredIndex sets the value for the ClusteredIndex field.
func (*CreateCollectionOptions)SetCollation¶added inv1.4.0
func (c *CreateCollectionOptions) SetCollation(collation *Collation) *CreateCollectionOptions
SetCollation sets the value for the Collation field.
func (*CreateCollectionOptions)SetDefaultIndexOptions¶added inv1.4.0
func (c *CreateCollectionOptions) SetDefaultIndexOptions(opts *DefaultIndexOptions) *CreateCollectionOptions
SetDefaultIndexOptions sets the value for the DefaultIndexOptions field.
func (*CreateCollectionOptions)SetEncryptedFields¶added inv1.10.0
func (c *CreateCollectionOptions) SetEncryptedFields(encryptedFields interface{}) *CreateCollectionOptions
SetEncryptedFields sets the encrypted fields for encrypted collections.
func (*CreateCollectionOptions)SetExpireAfterSeconds¶added inv1.6.0
func (c *CreateCollectionOptions) SetExpireAfterSeconds(easint64) *CreateCollectionOptions
SetExpireAfterSeconds sets the value for the ExpireAfterSeconds field.
func (*CreateCollectionOptions)SetMaxDocuments¶added inv1.4.0
func (c *CreateCollectionOptions) SetMaxDocuments(maxint64) *CreateCollectionOptions
SetMaxDocuments sets the value for the MaxDocuments field.
func (*CreateCollectionOptions)SetSizeInBytes¶added inv1.4.0
func (c *CreateCollectionOptions) SetSizeInBytes(sizeint64) *CreateCollectionOptions
SetSizeInBytes sets the value for the SizeInBytes field.
func (*CreateCollectionOptions)SetStorageEngine¶added inv1.4.0
func (c *CreateCollectionOptions) SetStorageEngine(storageEngine interface{}) *CreateCollectionOptions
SetStorageEngine sets the value for the StorageEngine field.
func (*CreateCollectionOptions)SetTimeSeriesOptions¶added inv1.6.0
func (c *CreateCollectionOptions) SetTimeSeriesOptions(timeSeriesOpts *TimeSeriesOptions) *CreateCollectionOptions
SetTimeSeriesOptions sets the options for time-series collections.
func (*CreateCollectionOptions)SetValidationAction¶added inv1.4.0
func (c *CreateCollectionOptions) SetValidationAction(actionstring) *CreateCollectionOptions
SetValidationAction sets the value for the ValidationAction field.
func (*CreateCollectionOptions)SetValidationLevel¶added inv1.4.0
func (c *CreateCollectionOptions) SetValidationLevel(levelstring) *CreateCollectionOptions
SetValidationLevel sets the value for the ValidationLevel field.
func (*CreateCollectionOptions)SetValidator¶added inv1.4.0
func (c *CreateCollectionOptions) SetValidator(validator interface{}) *CreateCollectionOptions
SetValidator sets the value for the Validator field.
typeCreateIndexesOptions¶added inv0.1.0
type CreateIndexesOptions struct {// The number of data-bearing members of a replica set, including the primary, that must complete the index builds// successfully before the primary marks the indexes as ready. This should either be a string or int32 value. The// semantics of the values are as follows://// 1. String: specifies a tag. All members with that tag must complete the build.// 2. int: the number of members that must complete the build.// 3. "majority": A special value to indicate that more than half the nodes must complete the build.// 4. "votingMembers": A special value to indicate that all voting data-bearing nodes must complete.//// This option is only available on MongoDB versions >= 4.4. A client-side error will be returned if the option// is specified for MongoDB versions <= 4.2. The default value is nil, meaning that the server-side default will be// used. See dochub.mongodb.org/core/index-commit-quorum for more information.CommitQuorum interface{}// The maximum amount of time that the query can run on the server. The default value is nil, meaning that there// is no time limit for query execution.//// NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeout option may be used// in its place to control the amount of time that a single operation can run before returning an error. MaxTime// is ignored if Timeout is set on the client.MaxTime *time.Duration}CreateIndexesOptions represents options that can be used to configure IndexView.CreateOne and IndexView.CreateManyoperations.
funcCreateIndexes¶added inv0.1.0
func CreateIndexes() *CreateIndexesOptions
CreateIndexes creates a new CreateIndexesOptions instance.
funcMergeCreateIndexesOptionsdeprecatedadded inv0.1.0
func MergeCreateIndexesOptions(opts ...*CreateIndexesOptions) *CreateIndexesOptions
MergeCreateIndexesOptions combines the given CreateIndexesOptions into a single CreateIndexesOptions in a last onewins fashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create asingle options struct instead.
func (*CreateIndexesOptions)SetCommitQuorumInt¶added inv1.4.0
func (c *CreateIndexesOptions) SetCommitQuorumInt(quorumint32) *CreateIndexesOptions
SetCommitQuorumInt sets the value for the CommitQuorum field as an int32.
func (*CreateIndexesOptions)SetCommitQuorumMajority¶added inv1.4.0
func (c *CreateIndexesOptions) SetCommitQuorumMajority() *CreateIndexesOptions
SetCommitQuorumMajority sets the value for the CommitQuorum to special "majority" value.
func (*CreateIndexesOptions)SetCommitQuorumString¶added inv1.4.0
func (c *CreateIndexesOptions) SetCommitQuorumString(quorumstring) *CreateIndexesOptions
SetCommitQuorumString sets the value for the CommitQuorum field as a string.
func (*CreateIndexesOptions)SetCommitQuorumVotingMembers¶added inv1.4.0
func (c *CreateIndexesOptions) SetCommitQuorumVotingMembers() *CreateIndexesOptions
SetCommitQuorumVotingMembers sets the value for the CommitQuorum to special "votingMembers" value.
func (*CreateIndexesOptions)SetMaxTime¶added inv0.1.0
func (c *CreateIndexesOptions) SetMaxTime(dtime.Duration) *CreateIndexesOptions
SetMaxTime sets the value for the MaxTime field.
NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeoutoption may be used in its place to control the amount of time that a single operation canrun before returning an error. MaxTime is ignored if Timeout is set on the client.
typeCreateSearchIndexesOptions¶added inv1.13.0
type CreateSearchIndexesOptions struct {}CreateSearchIndexesOptions represents options that can be used to configure a SearchIndexView.CreateOne orSearchIndexView.CreateMany operation.
typeCreateViewOptions¶added inv1.4.0
type CreateViewOptions struct {// Specifies the default collation for the new collection. This option is only valid for MongoDB versions >= 3.4.// For previous server versions, the driver will return an error if this option is used. The default value is nil.Collation *Collation}CreateViewOptions represents options that can be used to configure a CreateView operation.
funcCreateView¶added inv1.4.0
func CreateView() *CreateViewOptions
CreateView creates an new CreateViewOptions instance.
funcMergeCreateViewOptionsdeprecatedadded inv1.4.0
func MergeCreateViewOptions(opts ...*CreateViewOptions) *CreateViewOptions
MergeCreateViewOptions combines the given CreateViewOptions instances into a single CreateViewOptions in alast-one-wins fashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create asingle options struct instead.
func (*CreateViewOptions)SetCollation¶added inv1.4.0
func (c *CreateViewOptions) SetCollation(collation *Collation) *CreateViewOptions
SetCollation sets the value for the Collation field.
typeCredential¶added inv0.1.0
type Credential struct {AuthMechanismstringAuthMechanismProperties map[string]stringAuthSourcestringUsernamestringPasswordstringPasswordSetboolOIDCMachineCallbackOIDCCallbackOIDCHumanCallbackOIDCCallback}Credential can be used to provide authentication options when configuring a Client.
AuthMechanism: the mechanism to use for authentication. Supported values include "SCRAM-SHA-256", "SCRAM-SHA-1","MONGODB-CR", "PLAIN", "GSSAPI", "MONGODB-X509", and "MONGODB-AWS". This can also be set through the "authMechanism"URI option. (e.g. "authMechanism=PLAIN"). For more information, seehttps://www.mongodb.com/docs/manual/core/authentication-mechanisms/.
AuthMechanismProperties can be used to specify additional configuration options for certain mechanisms. They can alsobe set through the "authMechanismProperites" URI option(e.g. "authMechanismProperties=SERVICE_NAME:service,CANONICALIZE_HOST_NAME:true"). Supported properties are:
1. SERVICE_NAME: The service name to use for GSSAPI authentication. The default is "mongodb".
2. CANONICALIZE_HOST_NAME: If "true", the driver will canonicalize the host name for GSSAPI authentication. The defaultis "false".
3. SERVICE_REALM: The service realm for GSSAPI authentication.
4. SERVICE_HOST: The host name to use for GSSAPI authentication. This should be specified if the host name to use forauthentication is different than the one given for Client construction.
4. AWS_SESSION_TOKEN: The AWS token for MONGODB-AWS authentication. This is optional and used for authentication withtemporary credentials.
The SERVICE_HOST and CANONICALIZE_HOST_NAME properties must not be used at the same time on Linux and Darwinsystems.
AuthSource: the name of the database to use for authentication. This defaults to "$external" for MONGODB-AWS,MONGODB-OIDC, MONGODB-X509, GSSAPI, and PLAIN. It defaults to "admin" for all other auth mechanisms. This canalso be set through the "authSource" URI option (e.g. "authSource=otherDb").
Username: the username for authentication. This can also be set through the URI as a username:password pair beforethe first @ character. For example, a URI for user "user", password "pwd", and host "localhost:27017" would be"mongodb://user:pwd@localhost:27017". This is optional for X509 authentication and will be extracted from theclient certificate if not specified.
Password: the password for authentication. This must not be specified for X509 and is optional for GSSAPIauthentication.
PasswordSet: For GSSAPI, this must be true if a password is specified, even if the password is the empty string, andfalse if no password is specified, indicating that the password should be taken from the context of the runningprocess. For other mechanisms, this field is ignored.
typeCursorType¶
type CursorTypeint8
CursorType specifies whether a cursor should close when the last data is retrieved. SeeNonTailable, Tailable, and TailableAwait.
const (// NonTailable specifies that a cursor should close after retrieving the last data.NonTailableCursorType =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)
typeDataKeyOptions¶added inv1.2.0
type DataKeyOptions struct {MasterKey interface{}KeyAltNames []string// KeyMaterial is used to encrypt data. If omitted, keyMaterial is generated form a cryptographically secure random// source. "Key Material" is used interchangeably with "dataKey" and "Data Encryption Key" (DEK).KeyMaterial []byte}DataKeyOptions represents all possible options used to create a new data key.
funcDataKey¶added inv1.2.0
func DataKey() *DataKeyOptions
DataKey creates a new DataKeyOptions instance.
funcMergeDataKeyOptionsdeprecatedadded inv1.2.0
func MergeDataKeyOptions(opts ...*DataKeyOptions) *DataKeyOptions
MergeDataKeyOptions combines the argued DataKeyOptions in a last-one wins fashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create asingle options struct instead.
func (*DataKeyOptions)SetKeyAltNames¶added inv1.2.0
func (dk *DataKeyOptions) SetKeyAltNames(keyAltNames []string) *DataKeyOptions
SetKeyAltNames specifies an optional list of string alternate names used to reference a key. If a key is created'with alternate names, encryption may refer to the key by a unique alternate name instead of by _id.
func (*DataKeyOptions)SetKeyMaterial¶added inv1.10.0
func (dk *DataKeyOptions) SetKeyMaterial(keyMaterial []byte) *DataKeyOptions
SetKeyMaterial will set a custom keyMaterial to DataKeyOptions which can be used to encrypt data.
func (*DataKeyOptions)SetMasterKey¶added inv1.2.0
func (dk *DataKeyOptions) SetMasterKey(masterKey interface{}) *DataKeyOptions
SetMasterKey specifies a KMS-specific key used to encrypt the new data key.
If being used with a local KMS provider, this option is not applicable and should not be specified.
For the AWS, Azure, and GCP KMS providers, this option is required and must be a document. For each, the value of the"endpoint" or "keyVaultEndpoint" must be a host name with an optional port number (e.g. "foo.com" or "foo.com:443").
When using AWS, the document must have the format:
{ region: <string>, key: <string>, // The Amazon Resource Name (ARN) to the AWS customer master key (CMK). endpoint: Optional<string> // An alternate host identifier to send KMS requests to.}If unset, the "endpoint" defaults to "kms.<region>.amazonaws.com".
When using Azure, the document must have the format:
{ keyVaultEndpoint: <string>, // A host identifier to send KMS requests to. keyName: <string>, keyVersion: Optional<string> // A specific version of the named key.}If unset, "keyVersion" defaults to the key's primary version.
When using GCP, the document must have the format:
{ projectId: <string>, location: <string>, keyRing: <string>, keyName: <string>, keyVersion: Optional<string>, // A specific version of the named key. endpoint: Optional<string> // An alternate host identifier to send KMS requests to.}If unset, "keyVersion" defaults to the key's primary version and "endpoint" defaults to "cloudkms.googleapis.com".
typeDatabaseOptions¶added inv0.1.0
type DatabaseOptions struct {// ReadConcern is the read concern to use for operations executed on the Database. The default value is nil, which means that// the read concern of the Client used to configure the Database will be used.ReadConcern *readconcern.ReadConcern// WriteConcern is the write concern to use for operations executed on the Database. The default value is nil, which means that the// write concern of the Client used to configure the Database will be used.WriteConcern *writeconcern.WriteConcern// ReadPreference is the read preference to use for operations executed on the Database. The default value is nil, which means that// the read preference of the Client used to configure the Database will be used.ReadPreference *readpref.ReadPref// BSONOptions configures optional BSON marshaling and unmarshaling// behavior.BSONOptions *BSONOptions// Registry is the BSON registry to marshal and unmarshal documents for operations executed on the Database. The default value// is nil, which means that the registry of the Client used to configure the Database will be used.Registry *bsoncodec.Registry}DatabaseOptions represents options that can be used to configure a Database.
funcDatabase¶added inv0.1.0
func Database() *DatabaseOptions
Database creates a new DatabaseOptions instance.
funcMergeDatabaseOptionsdeprecatedadded inv0.1.0
func MergeDatabaseOptions(opts ...*DatabaseOptions) *DatabaseOptions
MergeDatabaseOptions combines the given DatabaseOptions instances into a single DatabaseOptions in a last-one-winsfashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create asingle options struct instead.
func (*DatabaseOptions)SetBSONOptions¶added inv1.12.0
func (d *DatabaseOptions) SetBSONOptions(opts *BSONOptions) *DatabaseOptions
SetBSONOptions configures optional BSON marshaling and unmarshaling behavior.
func (*DatabaseOptions)SetReadConcern¶added inv0.1.0
func (d *DatabaseOptions) SetReadConcern(rc *readconcern.ReadConcern) *DatabaseOptions
SetReadConcern sets the value for the ReadConcern field.
func (*DatabaseOptions)SetReadPreference¶added inv0.1.0
func (d *DatabaseOptions) SetReadPreference(rp *readpref.ReadPref) *DatabaseOptions
SetReadPreference sets the value for the ReadPreference field.
func (*DatabaseOptions)SetRegistry¶added inv0.1.0
func (d *DatabaseOptions) SetRegistry(r *bsoncodec.Registry) *DatabaseOptions
SetRegistry sets the value for the Registry field.
func (*DatabaseOptions)SetWriteConcern¶added inv0.1.0
func (d *DatabaseOptions) SetWriteConcern(wc *writeconcern.WriteConcern) *DatabaseOptions
SetWriteConcern sets the value for the WriteConcern field.
typeDefaultIndexOptions¶added inv1.4.0
type DefaultIndexOptions struct {// Specifies the storage engine to use for the index. The value must be a document in the form// {<storage engine name>: <options>}. The default value is nil, which means that the default storage engine// will be used.StorageEngine interface{}}DefaultIndexOptions represents the default options for a collection to apply on new indexes. This type can be usedwhen creating a new collection through the CreateCollectionOptions.SetDefaultIndexOptions method.
funcDefaultIndex¶added inv1.4.0
func DefaultIndex() *DefaultIndexOptions
DefaultIndex creates a new DefaultIndexOptions instance.
func (*DefaultIndexOptions)SetStorageEngine¶added inv1.4.0
func (d *DefaultIndexOptions) SetStorageEngine(storageEngine interface{}) *DefaultIndexOptions
SetStorageEngine sets the value for the StorageEngine field.
typeDeleteOptions¶added inv0.1.0
type DeleteOptions struct {// Specifies a collation to use for string comparisons during the operation. This option is only valid for MongoDB// versions >= 3.4. For previous server versions, the driver will return an error if this option is used. The// default value is nil, which means the default collation of the collection will be used.Collation *Collation// A string or document that will be included in server logs, profiling logs, and currentOp queries to help trace// the operation. The default value is nil, which means that no comment will be included in the logs.Comment interface{}// The index to use for the operation. This should either be the index name as a string or the index specification// as a document. This option is only valid for MongoDB versions >= 4.4. Server versions >= 3.4 will return an error// if this option is specified. For server versions < 3.4, the driver will return a client-side error if this option// is specified. The driver will return an error if this option is specified during an unacknowledged write// operation. The driver will return an error if the hint parameter is a multi-key map. The default value is nil,// which means that no hint will be sent.Hint interface{}// Specifies parameters for the delete expression. This option is only valid for MongoDB versions >= 5.0. Older// servers will report an error for using this option. This must be a document mapping parameter names to values.// Values must be constant or closed expressions that do not reference document fields. Parameters can then be// accessed as variables in an aggregate expression context (e.g. "$$var").Let interface{}}DeleteOptions represents options that can be used to configure DeleteOne and DeleteMany operations.
funcMergeDeleteOptionsdeprecatedadded inv0.1.0
func MergeDeleteOptions(opts ...*DeleteOptions) *DeleteOptions
MergeDeleteOptions combines the given DeleteOptions instances into a single DeleteOptions in a last-one-wins fashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create asingle options struct instead.
func (*DeleteOptions)SetCollation¶added inv0.1.0
func (do *DeleteOptions) SetCollation(c *Collation) *DeleteOptions
SetCollation sets the value for the Collation field.
func (*DeleteOptions)SetComment¶added inv1.10.0
func (do *DeleteOptions) SetComment(comment interface{}) *DeleteOptions
SetComment sets the value for the Comment field.
func (*DeleteOptions)SetHint¶added inv1.4.0
func (do *DeleteOptions) SetHint(hint interface{}) *DeleteOptions
SetHint sets the value for the Hint field.
func (*DeleteOptions)SetLet¶added inv1.9.0
func (do *DeleteOptions) SetLet(let interface{}) *DeleteOptions
SetLet sets the value for the Let field.
typeDistinctOptions¶added inv0.1.0
type DistinctOptions struct {// Specifies a collation to use for string comparisons during the operation. This option is only valid for MongoDB// versions >= 3.4. For previous server versions, the driver will return an error if this option is used. The// default value is nil, which means the default collation of the collection will be used.Collation *Collation// A string or document that will be included in server logs, profiling logs, and currentOp queries to help trace// the operation. The default value is nil, which means that no comment will be included in the logs.Comment interface{}// The maximum amount of time that the query can run on the server. The default value is nil, meaning that there// is no time limit for query execution.//// NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeout option may be// used in its place to control the amount of time that a single operation can run before returning an error.// MaxTime is ignored if Timeout is set on the client.MaxTime *time.Duration}DistinctOptions represents options that can be used to configure a Distinct operation.
funcDistinct¶added inv0.1.0
func Distinct() *DistinctOptions
Distinct creates a new DistinctOptions instance.
funcMergeDistinctOptionsdeprecatedadded inv0.1.0
func MergeDistinctOptions(opts ...*DistinctOptions) *DistinctOptions
MergeDistinctOptions combines the given DistinctOptions instances into a single DistinctOptions in a last-one-winsfashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create asingle options struct instead.
func (*DistinctOptions)SetCollation¶added inv0.1.0
func (do *DistinctOptions) SetCollation(c *Collation) *DistinctOptions
SetCollation sets the value for the Collation field.
func (*DistinctOptions)SetComment¶added inv1.10.0
func (do *DistinctOptions) SetComment(comment interface{}) *DistinctOptions
SetComment sets the value for the Comment field.
func (*DistinctOptions)SetMaxTime¶added inv0.1.0
func (do *DistinctOptions) SetMaxTime(dtime.Duration) *DistinctOptions
SetMaxTime sets the value for the MaxTime field.
NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeoutoption may be used in its place to control the amount of time that a single operation canrun before returning an error. MaxTime is ignored if Timeout is set on the client.
typeDropIndexesOptions¶added inv0.1.0
type DropIndexesOptions struct {// The maximum amount of time that the query can run on the server. The default value is nil, meaning that there// is no time limit for query execution.//// NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeout option may be used// in its place to control the amount of time that a single operation can run before returning an error. MaxTime// is ignored if Timeout is set on the client.MaxTime *time.Duration}DropIndexesOptions represents options that can be used to configure IndexView.DropOne and IndexView.DropAlloperations.
funcDropIndexes¶added inv0.1.0
func DropIndexes() *DropIndexesOptions
DropIndexes creates a new DropIndexesOptions instance.
funcMergeDropIndexesOptionsdeprecatedadded inv0.1.0
func MergeDropIndexesOptions(opts ...*DropIndexesOptions) *DropIndexesOptions
MergeDropIndexesOptions combines the given DropIndexesOptions into a single DropIndexesOptions in a last-one-winsfashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create asingle options struct instead.
func (*DropIndexesOptions)SetMaxTime¶added inv0.1.0
func (d *DropIndexesOptions) SetMaxTime(durationtime.Duration) *DropIndexesOptions
SetMaxTime sets the value for the MaxTime field.
NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeoutoption may be used in its place to control the amount of time that a single operation canrun before returning an error. MaxTime is ignored if Timeout is set on the client.
typeDropSearchIndexOptions¶added inv1.13.0
type DropSearchIndexOptions struct {}DropSearchIndexOptions represents options that can be used to configure a SearchIndexView.DropOne operation.
typeEncryptOptions¶added inv1.2.0
type EncryptOptions struct {KeyID *primitive.BinaryKeyAltName *stringAlgorithmstringQueryTypestringContentionFactor *int64RangeOptions *RangeOptions}EncryptOptions represents options to explicitly encrypt a value.
funcEncrypt¶added inv1.2.0
func Encrypt() *EncryptOptions
Encrypt creates a new EncryptOptions instance.
funcMergeEncryptOptionsdeprecatedadded inv1.2.0
func MergeEncryptOptions(opts ...*EncryptOptions) *EncryptOptions
MergeEncryptOptions combines the argued EncryptOptions in a last-one wins fashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create asingle options struct instead.
func (*EncryptOptions)SetAlgorithm¶added inv1.2.0
func (e *EncryptOptions) SetAlgorithm(algorithmstring) *EncryptOptions
SetAlgorithm specifies an algorithm to use for encryption. This should be one of the following:- AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic- AEAD_AES_256_CBC_HMAC_SHA_512-Random- Indexed- Unindexed- RangeThis is required.Indexed and Unindexed are used for Queryable Encryption.
func (*EncryptOptions)SetContentionFactor¶added inv1.10.0
func (e *EncryptOptions) SetContentionFactor(contentionFactorint64) *EncryptOptions
SetContentionFactor specifies the contention factor. It is only valid to set if algorithm is "Indexed".ContentionFactor is used for Queryable Encryption.
func (*EncryptOptions)SetKeyAltName¶added inv1.2.0
func (e *EncryptOptions) SetKeyAltName(keyAltNamestring) *EncryptOptions
SetKeyAltName identifies a key vault document by 'keyAltName'.
func (*EncryptOptions)SetKeyID¶added inv1.2.0
func (e *EncryptOptions) SetKeyID(keyIDprimitive.Binary) *EncryptOptions
SetKeyID specifies an _id of a data key. This should be a UUID (a primitive.Binary with subtype 4).
func (*EncryptOptions)SetQueryType¶added inv1.10.0
func (e *EncryptOptions) SetQueryType(queryTypestring) *EncryptOptions
SetQueryType specifies the intended query type. It is only valid to set if algorithm is "Indexed".This should be one of the following:- equalityQueryType is used for Queryable Encryption.
func (*EncryptOptions)SetRangeOptions¶added inv1.12.0
func (e *EncryptOptions) SetRangeOptions(roRangeOptions) *EncryptOptions
SetRangeOptions specifies the options to use for explicit encryption with range. It is only valid to set if algorithm is "Range".
typeEstimatedDocumentCountOptions¶added inv0.1.0
type EstimatedDocumentCountOptions struct {// A string or document that will be included in server logs, profiling logs, and currentOp queries to help trace// the operation. The default is nil, which means that no comment will be included in the logs.Comment interface{}// The maximum amount of time that the query can run on the server. The default value is nil, meaning that there// is no time limit for query execution.//// NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeout option may be used// in its place to control the amount of time that a single operation can run before returning an error. MaxTime// is ignored if Timeout is set on the client.MaxTime *time.Duration}EstimatedDocumentCountOptions represents options that can be used to configure an EstimatedDocumentCount operation.
funcEstimatedDocumentCount¶added inv0.1.0
func EstimatedDocumentCount() *EstimatedDocumentCountOptions
EstimatedDocumentCount creates a new EstimatedDocumentCountOptions instance.
funcMergeEstimatedDocumentCountOptionsdeprecatedadded inv0.1.0
func MergeEstimatedDocumentCountOptions(opts ...*EstimatedDocumentCountOptions) *EstimatedDocumentCountOptions
MergeEstimatedDocumentCountOptions combines the given EstimatedDocumentCountOptions instances into a singleEstimatedDocumentCountOptions in a last-one-wins fashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create asingle options struct instead.
func (*EstimatedDocumentCountOptions)SetComment¶added inv1.10.0
func (eco *EstimatedDocumentCountOptions) SetComment(comment interface{}) *EstimatedDocumentCountOptions
SetComment sets the value for the Comment field.
func (*EstimatedDocumentCountOptions)SetMaxTime¶added inv0.1.0
func (eco *EstimatedDocumentCountOptions) SetMaxTime(dtime.Duration) *EstimatedDocumentCountOptions
SetMaxTime sets the value for the MaxTime field.
NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeout optionmay be used in its place to control the amount of time that a single operation can run beforereturning an error. MaxTime is ignored if Timeout is set on the client.
typeFindOneAndDeleteOptions¶added inv0.1.0
type FindOneAndDeleteOptions struct {// Specifies a collation to use for string comparisons during the operation. This option is only valid for MongoDB// versions >= 3.4. For previous server versions, the driver will return an error if this option is used. The// default value is nil, which means the default collation of the collection will be used.Collation *Collation// A string or document that will be included in server logs, profiling logs, and currentOp queries to help trace// the operation. The default value is nil, which means that no comment will be included in the logs.Comment interface{}// The maximum amount of time that the query can run on the server. The default value is nil, meaning that there// is no time limit for query execution.//// NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeout option may be used// in its place to control the amount of time that a single operation can run before returning an error. MaxTime// is ignored if Timeout is set on the client.MaxTime *time.Duration// A document describing which fields will be included in the document returned by the operation. The default value// is nil, which means all fields will be included.Projection interface{}// A document specifying which document should be replaced if the filter used by the operation matches multiple// documents in the collection. If set, the first document in the sorted order will be selected for replacement.// The driver will return an error if the sort parameter is a multi-key map. The default value is nil.Sort interface{}// The index to use for the operation. This should either be the index name as a string or the index specification// as a document. This option is only valid for MongoDB versions >= 4.4. MongoDB version 4.2 will report an error if// this option is specified. For server versions < 4.2, the driver will return an error if this option is specified.// The driver will return an error if this option is used with during an unacknowledged write operation. The driver// will return an error if the hint parameter is a multi-key map. The default value is nil, which means that no hint// will be sent.Hint interface{}// Specifies parameters for the find one and delete expression. This option is only valid for MongoDB versions >= 5.0. Older// servers will report an error for using this option. This must be a document mapping parameter names to values.// Values must be constant or closed expressions that do not reference document fields. Parameters can then be// accessed as variables in an aggregate expression context (e.g. "$$var").Let interface{}}FindOneAndDeleteOptions represents options that can be used to configure a FindOneAndDelete operation.
funcFindOneAndDelete¶added inv0.1.0
func FindOneAndDelete() *FindOneAndDeleteOptions
FindOneAndDelete creates a new FindOneAndDeleteOptions instance.
funcMergeFindOneAndDeleteOptionsdeprecatedadded inv0.1.0
func MergeFindOneAndDeleteOptions(opts ...*FindOneAndDeleteOptions) *FindOneAndDeleteOptions
MergeFindOneAndDeleteOptions combines the given FindOneAndDeleteOptions instances into a singleFindOneAndDeleteOptions in a last-one-wins fashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create asingle options struct instead.
func (*FindOneAndDeleteOptions)SetCollation¶added inv0.1.0
func (f *FindOneAndDeleteOptions) SetCollation(collation *Collation) *FindOneAndDeleteOptions
SetCollation sets the value for the Collation field.
func (*FindOneAndDeleteOptions)SetComment¶added inv1.10.0
func (f *FindOneAndDeleteOptions) SetComment(comment interface{}) *FindOneAndDeleteOptions
SetComment sets the value for the Comment field.
func (*FindOneAndDeleteOptions)SetHint¶added inv1.4.0
func (f *FindOneAndDeleteOptions) SetHint(hint interface{}) *FindOneAndDeleteOptions
SetHint sets the value for the Hint field.
func (*FindOneAndDeleteOptions)SetLet¶added inv1.9.0
func (f *FindOneAndDeleteOptions) SetLet(let interface{}) *FindOneAndDeleteOptions
SetLet sets the value for the Let field.
func (*FindOneAndDeleteOptions)SetMaxTime¶added inv0.1.0
func (f *FindOneAndDeleteOptions) SetMaxTime(dtime.Duration) *FindOneAndDeleteOptions
SetMaxTime sets the value for the MaxTime field.
NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeoutoption may be used in its place to control the amount of time that a single operation canrun before returning an error. MaxTime is ignored if Timeout is set on the client.
func (*FindOneAndDeleteOptions)SetProjection¶added inv0.1.0
func (f *FindOneAndDeleteOptions) SetProjection(projection interface{}) *FindOneAndDeleteOptions
SetProjection sets the value for the Projection field.
func (*FindOneAndDeleteOptions)SetSort¶added inv0.1.0
func (f *FindOneAndDeleteOptions) SetSort(sort interface{}) *FindOneAndDeleteOptions
SetSort sets the value for the Sort field.
typeFindOneAndReplaceOptions¶added inv0.1.0
type FindOneAndReplaceOptions struct {// If true, writes executed as part of the operation will opt out of document-level validation on the server. This// option is valid for MongoDB versions >= 3.2 and is ignored for previous server versions. The default value is// false. Seehttps://www.mongodb.com/docs/manual/core/schema-validation/ for more information about document// validation.BypassDocumentValidation *bool// Specifies a collation to use for string comparisons during the operation. This option is only valid for MongoDB// versions >= 3.4. For previous server versions, the driver will return an error if this option is used. The// default value is nil, which means the default collation of the collection will be used.Collation *Collation// A string or document that will be included in server logs, profiling logs, and currentOp queries to help trace// the operation. The default value is nil, which means that no comment will be included in the logs.Comment interface{}// The maximum amount of time that the query can run on the server. The default value is nil, meaning that there// is no time limit for query execution.//// NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeout option may be used// in its place to control the amount of time that a single operation can run before returning an error. MaxTime// is ignored if Timeout is set on the client.MaxTime *time.Duration// A document describing which fields will be included in the document returned by the operation. The default value// is nil, which means all fields will be included.Projection interface{}// Specifies whether the original or replaced document should be returned by the operation. The default value is// Before, which means the original document will be returned from before the replacement is performed.ReturnDocument *ReturnDocument// A document specifying which document should be replaced if the filter used by the operation matches multiple// documents in the collection. If set, the first document in the sorted order will be replaced. The driver will// return an error if the sort parameter is a multi-key map. The default value is nil.Sort interface{}// If true, a new document will be inserted if the filter does not match any documents in the collection. The// default value is false.Upsert *bool// The index to use for the operation. This should either be the index name as a string or the index specification// as a document. This option is only valid for MongoDB versions >= 4.4. MongoDB version 4.2 will report an error if// this option is specified. For server versions < 4.2, the driver will return an error if this option is specified.// The driver will return an error if this option is used with during an unacknowledged write operation. The driver// will return an error if the hint parameter is a multi-key map. The default value is nil, which means that no hint// will be sent.Hint interface{}// Specifies parameters for the find one and replace expression. This option is only valid for MongoDB versions >= 5.0. Older// servers will report an error for using this option. This must be a document mapping parameter names to values.// Values must be constant or closed expressions that do not reference document fields. Parameters can then be// accessed as variables in an aggregate expression context (e.g. "$$var").Let interface{}// If true, the server accepts empty Timestamp as a literal rather than replacing it with the current time.//// Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any// release.BypassEmptyTsReplacement *bool}FindOneAndReplaceOptions represents options that can be used to configure a FindOneAndReplace instance.
funcFindOneAndReplace¶added inv0.1.0
func FindOneAndReplace() *FindOneAndReplaceOptions
FindOneAndReplace creates a new FindOneAndReplaceOptions instance.
funcMergeFindOneAndReplaceOptionsdeprecatedadded inv0.1.0
func MergeFindOneAndReplaceOptions(opts ...*FindOneAndReplaceOptions) *FindOneAndReplaceOptions
MergeFindOneAndReplaceOptions combines the given FindOneAndReplaceOptions instances into a singleFindOneAndReplaceOptions in a last-one-wins fashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create asingle options struct instead.
func (*FindOneAndReplaceOptions)SetBypassDocumentValidation¶added inv0.1.0
func (f *FindOneAndReplaceOptions) SetBypassDocumentValidation(bbool) *FindOneAndReplaceOptions
SetBypassDocumentValidation sets the value for the BypassDocumentValidation field.
func (*FindOneAndReplaceOptions)SetCollation¶added inv0.1.0
func (f *FindOneAndReplaceOptions) SetCollation(collation *Collation) *FindOneAndReplaceOptions
SetCollation sets the value for the Collation field.
func (*FindOneAndReplaceOptions)SetComment¶added inv1.10.0
func (f *FindOneAndReplaceOptions) SetComment(comment interface{}) *FindOneAndReplaceOptions
SetComment sets the value for the Comment field.
func (*FindOneAndReplaceOptions)SetHint¶added inv1.4.0
func (f *FindOneAndReplaceOptions) SetHint(hint interface{}) *FindOneAndReplaceOptions
SetHint sets the value for the Hint field.
func (*FindOneAndReplaceOptions)SetLet¶added inv1.9.0
func (f *FindOneAndReplaceOptions) SetLet(let interface{}) *FindOneAndReplaceOptions
SetLet sets the value for the Let field.
func (*FindOneAndReplaceOptions)SetMaxTime¶added inv0.1.0
func (f *FindOneAndReplaceOptions) SetMaxTime(dtime.Duration) *FindOneAndReplaceOptions
SetMaxTime sets the value for the MaxTime field.
NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeoutoption may be used in its place to control the amount of time that a single operation canrun before returning an error. MaxTime is ignored if Timeout is set on the client.
func (*FindOneAndReplaceOptions)SetProjection¶added inv0.1.0
func (f *FindOneAndReplaceOptions) SetProjection(projection interface{}) *FindOneAndReplaceOptions
SetProjection sets the value for the Projection field.
func (*FindOneAndReplaceOptions)SetReturnDocument¶added inv0.1.0
func (f *FindOneAndReplaceOptions) SetReturnDocument(rdReturnDocument) *FindOneAndReplaceOptions
SetReturnDocument sets the value for the ReturnDocument field.
func (*FindOneAndReplaceOptions)SetSort¶added inv0.1.0
func (f *FindOneAndReplaceOptions) SetSort(sort interface{}) *FindOneAndReplaceOptions
SetSort sets the value for the Sort field.
func (*FindOneAndReplaceOptions)SetUpsert¶added inv0.1.0
func (f *FindOneAndReplaceOptions) SetUpsert(bbool) *FindOneAndReplaceOptions
SetUpsert sets the value for the Upsert field.
typeFindOneAndUpdateOptions¶added inv0.1.0
type FindOneAndUpdateOptions struct {// A set of filters specifying to which array elements an update should apply. This option is only valid for MongoDB// versions >= 3.6. For previous server versions, the driver will return an error if this option is used. The// default value is nil, which means the update will apply to all array elements.ArrayFilters *ArrayFilters// If true, writes executed as part of the operation will opt out of document-level validation on the server. This// option is valid for MongoDB versions >= 3.2 and is ignored for previous server versions. The default value is// false. Seehttps://www.mongodb.com/docs/manual/core/schema-validation/ for more information about document// validation.BypassDocumentValidation *bool// Specifies a collation to use for string comparisons during the operation. This option is only valid for MongoDB// versions >= 3.4. For previous server versions, the driver will return an error if this option is used. The// default value is nil, which means the default collation of the collection will be used.Collation *Collation// A string or document that will be included in server logs, profiling logs, and currentOp queries to help trace// the operation. The default value is nil, which means that no comment will be included in the logs.Comment interface{}// The maximum amount of time that the query can run on the server. The default value is nil, meaning that there// is no time limit for query execution.//// NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeout option may be used// in its place to control the amount of time that a single operation can run before returning an error. MaxTime is// ignored if Timeout is set on the client.MaxTime *time.Duration// A document describing which fields will be included in the document returned by the operation. The default value// is nil, which means all fields will be included.Projection interface{}// Specifies whether the original or replaced document should be returned by the operation. The default value is// Before, which means the original document will be returned before the replacement is performed.ReturnDocument *ReturnDocument// A document specifying which document should be updated if the filter used by the operation matches multiple// documents in the collection. If set, the first document in the sorted order will be updated. The driver will// return an error if the sort parameter is a multi-key map. The default value is nil.Sort interface{}// If true, a new document will be inserted if the filter does not match any documents in the collection. The// default value is false.Upsert *bool// The index to use for the operation. This should either be the index name as a string or the index specification// as a document. This option is only valid for MongoDB versions >= 4.4. MongoDB version 4.2 will report an error if// this option is specified. For server versions < 4.2, the driver will return an error if this option is specified.// The driver will return an error if this option is used with during an unacknowledged write operation. The driver// will return an error if the hint parameter is a multi-key map. The default value is nil, which means that no hint// will be sent.Hint interface{}// Specifies parameters for the find one and update expression. This option is only valid for MongoDB versions >= 5.0. Older// servers will report an error for using this option. This must be a document mapping parameter names to values.// Values must be constant or closed expressions that do not reference document fields. Parameters can then be// accessed as variables in an aggregate expression context (e.g. "$$var").Let interface{}// If true, the server accepts empty Timestamp as a literal rather than replacing it with the current time.//// Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any// release.BypassEmptyTsReplacement *bool}FindOneAndUpdateOptions represents options that can be used to configure a FindOneAndUpdate options.
funcFindOneAndUpdate¶added inv0.1.0
func FindOneAndUpdate() *FindOneAndUpdateOptions
FindOneAndUpdate creates a new FindOneAndUpdateOptions instance.
funcMergeFindOneAndUpdateOptionsdeprecatedadded inv0.1.0
func MergeFindOneAndUpdateOptions(opts ...*FindOneAndUpdateOptions) *FindOneAndUpdateOptions
MergeFindOneAndUpdateOptions combines the given FindOneAndUpdateOptions instances into a singleFindOneAndUpdateOptions in a last-one-wins fashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create asingle options struct instead.
func (*FindOneAndUpdateOptions)SetArrayFilters¶added inv0.1.0
func (f *FindOneAndUpdateOptions) SetArrayFilters(filtersArrayFilters) *FindOneAndUpdateOptions
SetArrayFilters sets the value for the ArrayFilters field.
func (*FindOneAndUpdateOptions)SetBypassDocumentValidation¶added inv0.1.0
func (f *FindOneAndUpdateOptions) SetBypassDocumentValidation(bbool) *FindOneAndUpdateOptions
SetBypassDocumentValidation sets the value for the BypassDocumentValidation field.
func (*FindOneAndUpdateOptions)SetCollation¶added inv0.1.0
func (f *FindOneAndUpdateOptions) SetCollation(collation *Collation) *FindOneAndUpdateOptions
SetCollation sets the value for the Collation field.
func (*FindOneAndUpdateOptions)SetComment¶added inv1.10.0
func (f *FindOneAndUpdateOptions) SetComment(comment interface{}) *FindOneAndUpdateOptions
SetComment sets the value for the Comment field.
func (*FindOneAndUpdateOptions)SetHint¶added inv1.4.0
func (f *FindOneAndUpdateOptions) SetHint(hint interface{}) *FindOneAndUpdateOptions
SetHint sets the value for the Hint field.
func (*FindOneAndUpdateOptions)SetLet¶added inv1.9.0
func (f *FindOneAndUpdateOptions) SetLet(let interface{}) *FindOneAndUpdateOptions
SetLet sets the value for the Let field.
func (*FindOneAndUpdateOptions)SetMaxTime¶added inv0.1.0
func (f *FindOneAndUpdateOptions) SetMaxTime(dtime.Duration) *FindOneAndUpdateOptions
SetMaxTime sets the value for the MaxTime field.
NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeoutoption may be used in its place to control the amount of time that a single operation canrun before returning an error. MaxTime is ignored if Timeout is set on the client.
func (*FindOneAndUpdateOptions)SetProjection¶added inv0.1.0
func (f *FindOneAndUpdateOptions) SetProjection(projection interface{}) *FindOneAndUpdateOptions
SetProjection sets the value for the Projection field.
func (*FindOneAndUpdateOptions)SetReturnDocument¶added inv0.1.0
func (f *FindOneAndUpdateOptions) SetReturnDocument(rdReturnDocument) *FindOneAndUpdateOptions
SetReturnDocument sets the value for the ReturnDocument field.
func (*FindOneAndUpdateOptions)SetSort¶added inv0.1.0
func (f *FindOneAndUpdateOptions) SetSort(sort interface{}) *FindOneAndUpdateOptions
SetSort sets the value for the Sort field.
func (*FindOneAndUpdateOptions)SetUpsert¶added inv0.1.0
func (f *FindOneAndUpdateOptions) SetUpsert(bbool) *FindOneAndUpdateOptions
SetUpsert sets the value for the Upsert field.
typeFindOneOptions¶added inv0.1.0
type FindOneOptions struct {// If true, an operation on a sharded cluster can return partial results if some shards are down rather than// returning an error. The default value is false.AllowPartialResults *bool// The maximum number of documents to be included in each batch returned by the server.//// Deprecated: This option is not valid for a findOne operation, as no cursor is actually created.BatchSize *int32// Specifies a collation to use for string comparisons during the operation. This option is only valid for MongoDB// versions >= 3.4. For previous server versions, the driver will return an error if this option is used. The// default value is nil, which means the default collation of the collection will be used.Collation *Collation// A string that will be included in server logs, profiling logs, and currentOp queries to help trace the operation.// The default is nil, which means that no comment will be included in the logs.Comment *string// Specifies the type of cursor that should be created for the operation. The default is NonTailable, which means// that the cursor will be closed by the server when the last batch of documents is retrieved.//// Deprecated: This option is not valid for a findOne operation, as no cursor is actually created.CursorType *CursorType// The index to use for the aggregation. This should either be the index name as a string or the index specification// as a document. The driver will return an error if the hint parameter is a multi-key map. The default value is nil,// which means that no hint will be sent.Hint interface{}// A document specifying the exclusive upper bound for a specific index. The default value is nil, which means that// there is no maximum value.Max interface{}// The maximum amount of time that the server should wait for new documents to satisfy a tailable cursor query.// This option is only valid for tailable await cursors (see the CursorType option for more information) and// MongoDB versions >= 3.2. For other cursor types or previous server versions, this option is ignored.//// Deprecated: This option is not valid for a findOne operation, as no cursor is actually created.MaxAwaitTime *time.Duration// The maximum amount of time that the query can run on the server. The default value is nil, meaning that there// is no time limit for query execution.//// NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeout option may be used// in its place to control the amount of time that a single operation can run before returning an error. MaxTime// is ignored if Timeout is set on the client.MaxTime *time.Duration// A document specifying the inclusive lower bound for a specific index. The default value is 0, which means that// there is no minimum value.Min interface{}// If true, the cursor created by the operation will not timeout after a period of inactivity. The default value// is false.//// Deprecated: This option is not valid for a findOne operation, as no cursor is actually created.NoCursorTimeout *bool// This option is for internal replication use only and should not be set.//// Deprecated: This option has been deprecated in MongoDB version 4.4 and will be ignored by the server if it is// set.OplogReplay *bool// A document describing which fields will be included in the document returned by the operation. The default value// is nil, which means all fields will be included.Projection interface{}// If true, the document returned by the operation will only contain fields corresponding to the index used. The// default value is false.ReturnKey *bool// If true, a $recordId field with a record identifier will be included in the document returned by the operation.// The default value is false.ShowRecordID *bool// The number of documents to skip before selecting the document to be returned. The default value is 0.Skip *int64// If true, the cursor will not return a document more than once because of an intervening write operation. The// default value is false.//// Deprecated: This option has been deprecated in MongoDB version 3.6 and removed in MongoDB version 4.0.Snapshot *bool// A document specifying the sort order to apply to the query. The first document in the sorted order will be// returned. The driver will return an error if the sort parameter is a multi-key map.Sort interface{}}FindOneOptions represents options that can be used to configure a FindOne operation.
funcFindOne¶added inv0.1.0
func FindOne() *FindOneOptions
FindOne creates a new FindOneOptions instance.
funcMergeFindOneOptionsdeprecatedadded inv0.1.0
func MergeFindOneOptions(opts ...*FindOneOptions) *FindOneOptions
MergeFindOneOptions combines the given FindOneOptions instances into a single FindOneOptions in a last-one-winsfashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create asingle options struct instead.
func (*FindOneOptions)SetAllowPartialResults¶added inv0.1.0
func (f *FindOneOptions) SetAllowPartialResults(bbool) *FindOneOptions
SetAllowPartialResults sets the value for the AllowPartialResults field.
func (*FindOneOptions)SetBatchSizedeprecatedadded inv0.1.0
func (f *FindOneOptions) SetBatchSize(iint32) *FindOneOptions
SetBatchSize sets the value for the BatchSize field.
Deprecated: This option is not valid for a findOne operation, as no cursor is actually created.
func (*FindOneOptions)SetCollation¶added inv0.1.0
func (f *FindOneOptions) SetCollation(collation *Collation) *FindOneOptions
SetCollation sets the value for the Collation field.
func (*FindOneOptions)SetComment¶added inv0.1.0
func (f *FindOneOptions) SetComment(commentstring) *FindOneOptions
SetComment sets the value for the Comment field.
func (*FindOneOptions)SetCursorTypedeprecatedadded inv0.1.0
func (f *FindOneOptions) SetCursorType(ctCursorType) *FindOneOptions
SetCursorType sets the value for the CursorType field.
Deprecated: This option is not valid for a findOne operation, as no cursor is actually created.
func (*FindOneOptions)SetHint¶added inv0.1.0
func (f *FindOneOptions) SetHint(hint interface{}) *FindOneOptions
SetHint sets the value for the Hint field.
func (*FindOneOptions)SetMax¶added inv0.1.0
func (f *FindOneOptions) SetMax(max interface{}) *FindOneOptions
SetMax sets the value for the Max field.
func (*FindOneOptions)SetMaxAwaitTimedeprecatedadded inv0.1.0
func (f *FindOneOptions) SetMaxAwaitTime(dtime.Duration) *FindOneOptions
SetMaxAwaitTime sets the value for the MaxAwaitTime field.
Deprecated: This option is not valid for a findOne operation, as no cursor is actually created.
func (*FindOneOptions)SetMaxTime¶added inv0.1.0
func (f *FindOneOptions) SetMaxTime(dtime.Duration) *FindOneOptions
SetMaxTime sets the value for the MaxTime field.
NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeoutoption may be used in its place to control the amount of time that a single operation canrun before returning an error. MaxTime is ignored if Timeout is set on the client.
func (*FindOneOptions)SetMin¶added inv0.1.0
func (f *FindOneOptions) SetMin(min interface{}) *FindOneOptions
SetMin sets the value for the Min field.
func (*FindOneOptions)SetNoCursorTimeoutdeprecatedadded inv0.1.0
func (f *FindOneOptions) SetNoCursorTimeout(bbool) *FindOneOptions
SetNoCursorTimeout sets the value for the NoCursorTimeout field.
Deprecated: This option is not valid for a findOne operation, as no cursor is actually created.
func (*FindOneOptions)SetOplogReplaydeprecatedadded inv0.1.0
func (f *FindOneOptions) SetOplogReplay(bbool) *FindOneOptions
SetOplogReplay sets the value for the OplogReplay field.
Deprecated: This option has been deprecated in MongoDB version 4.4 and will be ignored by the server if it isset.
func (*FindOneOptions)SetProjection¶added inv0.1.0
func (f *FindOneOptions) SetProjection(projection interface{}) *FindOneOptions
SetProjection sets the value for the Projection field.
func (*FindOneOptions)SetReturnKey¶added inv0.1.0
func (f *FindOneOptions) SetReturnKey(bbool) *FindOneOptions
SetReturnKey sets the value for the ReturnKey field.
func (*FindOneOptions)SetShowRecordID¶added inv0.1.0
func (f *FindOneOptions) SetShowRecordID(bbool) *FindOneOptions
SetShowRecordID sets the value for the ShowRecordID field.
func (*FindOneOptions)SetSkip¶added inv0.1.0
func (f *FindOneOptions) SetSkip(iint64) *FindOneOptions
SetSkip sets the value for the Skip field.
func (*FindOneOptions)SetSnapshotdeprecatedadded inv0.1.0
func (f *FindOneOptions) SetSnapshot(bbool) *FindOneOptions
SetSnapshot sets the value for the Snapshot field.
Deprecated: This option has been deprecated in MongoDB version 3.6 and removed in MongoDB version 4.0.
func (*FindOneOptions)SetSort¶added inv0.1.0
func (f *FindOneOptions) SetSort(sort interface{}) *FindOneOptions
SetSort sets the value for the Sort field.
typeFindOptions¶added inv0.1.0
type FindOptions struct {// AllowDiskUse specifies whether the server can write temporary data to disk while executing the Find operation.// This option is only valid for MongoDB versions >= 4.4. Server versions >= 3.2 will report an error if this option// is specified. For server versions < 3.2, the driver will return a client-side error if this option is specified.// The default value is false.AllowDiskUse *bool// AllowPartial results specifies whether the Find operation on a sharded cluster can return partial results if some// shards are down rather than returning an error. The default value is false.AllowPartialResults *bool// BatchSize is the maximum number of documents to be included in each batch returned by the server.BatchSize *int32// Collation specifies a collation to use for string comparisons during the operation. This option is only valid for// MongoDB versions >= 3.4. For previous server versions, the driver will return an error if this option is used. The// default value is nil, which means the default collation of the collection will be used.Collation *Collation// A string that will be included in server logs, profiling logs, and currentOp queries to help trace the operation.// The default is nil, which means that no comment will be included in the logs.Comment *string// CursorType specifies the type of cursor that should be created for the operation. The default is NonTailable, which// means that the cursor will be closed by the server when the last batch of documents is retrieved.CursorType *CursorType// Hint is the index to use for the Find operation. This should either be the index name as a string or the index// specification as a document. The driver will return an error if the hint parameter is a multi-key map. The default// value is nil, which means that no hint will be sent.Hint interface{}// Limit is the maximum number of documents to return. The default value is 0, which means that all documents matching the// filter will be returned. A negative limit specifies that the resulting documents should be returned in a single// batch. The default value is 0.Limit *int64// Max is a document specifying the exclusive upper bound for a specific index. The default value is nil, which means that// there is no maximum value.Max interface{}// MaxAwaitTime is the maximum amount of time that the server should wait for new documents to satisfy a tailable cursor// query. This option is only valid for tailable await cursors (see the CursorType option for more information) and// MongoDB versions >= 3.2. For other cursor types or previous server versions, this option is ignored.MaxAwaitTime *time.Duration// MaxTime is the maximum amount of time that the query can run on the server. The default value is nil, meaning that there// is no time limit for query execution.//// NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeout option may be used in its// place to control the amount of time that a single operation can run before returning an error. MaxTime is ignored if// Timeout is set on the client.MaxTime *time.Duration// Min is a document specifying the inclusive lower bound for a specific index. The default value is 0, which means that// there is no minimum value.Min interface{}// NoCursorTimeout specifies whether the cursor created by the operation will not timeout after a period of inactivity.// The default value is false.NoCursorTimeout *bool// OplogReplay is for internal replication use only and should not be set.//// Deprecated: This option has been deprecated in MongoDB version 4.4 and will be ignored by the server if it is// set.OplogReplay *bool// Project is a document describing which fields will be included in the documents returned by the Find operation. The// default value is nil, which means all fields will be included.Projection interface{}// ReturnKey specifies whether the documents returned by the Find operation will only contain fields corresponding to the// index used. The default value is false.ReturnKey *bool// ShowRecordID specifies whether a $recordId field with a record identifier will be included in the documents returned by// the Find operation. The default value is false.ShowRecordID *bool// Skip is the number of documents to skip before adding documents to the result. The default value is 0.Skip *int64// Snapshot specifies whether the cursor will not return a document more than once because of an intervening write operation.// The default value is false.//// Deprecated: This option has been deprecated in MongoDB version 3.6 and removed in MongoDB version 4.0.Snapshot *bool// Sort is a document specifying the order in which documents should be returned. The driver will return an error if the// sort parameter is a multi-key map.Sort interface{}// Let specifies parameters for the find expression. This option is only valid for MongoDB versions >= 5.0. Older// servers will report an error for using this option. This must be a document mapping parameter names to values.// Values must be constant or closed expressions that do not reference document fields. Parameters can then be// accessed as variables in an aggregate expression context (e.g. "$$var").Let interface{}}FindOptions represents options that can be used to configure a Find operation.
funcMergeFindOptionsdeprecatedadded inv0.1.0
func MergeFindOptions(opts ...*FindOptions) *FindOptions
MergeFindOptions combines the given FindOptions instances into a single FindOptions in a last-one-wins fashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create asingle options struct instead.
func (*FindOptions)SetAllowDiskUse¶added inv1.4.0
func (f *FindOptions) SetAllowDiskUse(bbool) *FindOptions
SetAllowDiskUse sets the value for the AllowDiskUse field.
func (*FindOptions)SetAllowPartialResults¶added inv0.1.0
func (f *FindOptions) SetAllowPartialResults(bbool) *FindOptions
SetAllowPartialResults sets the value for the AllowPartialResults field.
func (*FindOptions)SetBatchSize¶added inv0.1.0
func (f *FindOptions) SetBatchSize(iint32) *FindOptions
SetBatchSize sets the value for the BatchSize field.
func (*FindOptions)SetCollation¶added inv0.1.0
func (f *FindOptions) SetCollation(collation *Collation) *FindOptions
SetCollation sets the value for the Collation field.
func (*FindOptions)SetComment¶added inv0.1.0
func (f *FindOptions) SetComment(commentstring) *FindOptions
SetComment sets the value for the Comment field.
func (*FindOptions)SetCursorType¶added inv0.1.0
func (f *FindOptions) SetCursorType(ctCursorType) *FindOptions
SetCursorType sets the value for the CursorType field.
func (*FindOptions)SetHint¶added inv0.1.0
func (f *FindOptions) SetHint(hint interface{}) *FindOptions
SetHint sets the value for the Hint field.
func (*FindOptions)SetLet¶added inv1.9.0
func (f *FindOptions) SetLet(let interface{}) *FindOptions
SetLet sets the value for the Let field.
func (*FindOptions)SetLimit¶added inv0.1.0
func (f *FindOptions) SetLimit(iint64) *FindOptions
SetLimit sets the value for the Limit field.
func (*FindOptions)SetMax¶added inv0.1.0
func (f *FindOptions) SetMax(max interface{}) *FindOptions
SetMax sets the value for the Max field.
func (*FindOptions)SetMaxAwaitTime¶added inv0.1.0
func (f *FindOptions) SetMaxAwaitTime(dtime.Duration) *FindOptions
SetMaxAwaitTime sets the value for the MaxAwaitTime field.
func (*FindOptions)SetMaxTime¶added inv0.1.0
func (f *FindOptions) SetMaxTime(dtime.Duration) *FindOptions
SetMaxTime specifies the max time to allow the query to run.
NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeoutoption may be used used in its place to control the amount of time that a single operationcan run before returning an error. MaxTime is ignored if Timeout is set on the client.
func (*FindOptions)SetMin¶added inv0.1.0
func (f *FindOptions) SetMin(min interface{}) *FindOptions
SetMin sets the value for the Min field.
func (*FindOptions)SetNoCursorTimeout¶added inv0.1.0
func (f *FindOptions) SetNoCursorTimeout(bbool) *FindOptions
SetNoCursorTimeout sets the value for the NoCursorTimeout field.
func (*FindOptions)SetOplogReplaydeprecatedadded inv0.1.0
func (f *FindOptions) SetOplogReplay(bbool) *FindOptions
SetOplogReplay sets the value for the OplogReplay field.
Deprecated: This option has been deprecated in MongoDB version 4.4 and will be ignored by the server if it is set.
func (*FindOptions)SetProjection¶added inv0.1.0
func (f *FindOptions) SetProjection(projection interface{}) *FindOptions
SetProjection sets the value for the Projection field.
func (*FindOptions)SetReturnKey¶added inv0.1.0
func (f *FindOptions) SetReturnKey(bbool) *FindOptions
SetReturnKey sets the value for the ReturnKey field.
func (*FindOptions)SetShowRecordID¶added inv0.1.0
func (f *FindOptions) SetShowRecordID(bbool) *FindOptions
SetShowRecordID sets the value for the ShowRecordID field.
func (*FindOptions)SetSkip¶added inv0.1.0
func (f *FindOptions) SetSkip(iint64) *FindOptions
SetSkip sets the value for the Skip field.
func (*FindOptions)SetSnapshotdeprecatedadded inv0.1.0
func (f *FindOptions) SetSnapshot(bbool) *FindOptions
SetSnapshot sets the value for the Snapshot field.
Deprecated: This option has been deprecated in MongoDB version 3.6 and removed in MongoDB version 4.0.
func (*FindOptions)SetSort¶added inv0.1.0
func (f *FindOptions) SetSort(sort interface{}) *FindOptions
SetSort sets the value for the Sort field.
typeFullDocument¶added inv0.1.0
type FullDocumentstring
FullDocument specifies how a change stream should return the modified document.
const (// Default does not include a document copy.DefaultFullDocument = "default"// Off is the same as sending no value for fullDocumentBeforeChange.OffFullDocument = "off"// Required is the same as WhenAvailable but raises a server-side error if the post-image is not available.RequiredFullDocument = "required"// UpdateLookup includes a delta describing the changes to the document and a copy of the entire document that// was changed.UpdateLookupFullDocument = "updateLookup"// WhenAvailable includes a post-image of the modified document for replace and update change events// if the post-image for this event is available.WhenAvailableFullDocument = "whenAvailable")
typeGridFSFindOptions¶added inv0.1.0
type GridFSFindOptions struct {// If true, the server can write temporary data to disk while executing the find operation. The default value// is false. This option is only valid for MongoDB versions >= 4.4. For previous server versions, the server will// return an error if this option is used.AllowDiskUse *bool// The maximum number of documents to be included in each batch returned by the server.BatchSize *int32// The maximum number of documents to return. The default value is 0, which means that all documents matching the// filter will be returned. A negative limit specifies that the resulting documents should be returned in a single// batch. The default value is 0.Limit *int32// The maximum amount of time that the query can run on the server. The default value is nil, meaning that there// is no time limit for query execution.//// NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeout option may be used// in its place to control the amount of time that a single operation can run before returning an error. MaxTime// is ignored if Timeout is set on the client.MaxTime *time.Duration// If true, the cursor created by the operation will not timeout after a period of inactivity. The default value// is false.NoCursorTimeout *bool// The number of documents to skip before adding documents to the result. The default value is 0.Skip *int32// A document specifying the order in which documents should be returned. The driver will return an error if the// sort parameter is a multi-key map.Sort interface{}}GridFSFindOptions represents options that can be used to configure a GridFS Find operation.
funcGridFSFind¶added inv0.1.0
func GridFSFind() *GridFSFindOptions
GridFSFind creates a new GridFSFindOptions instance.
funcMergeGridFSFindOptionsdeprecatedadded inv0.1.0
func MergeGridFSFindOptions(opts ...*GridFSFindOptions) *GridFSFindOptions
MergeGridFSFindOptions combines the given GridFSFindOptions instances into a single GridFSFindOptions in alast-one-wins fashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create asingle options struct instead.
func (*GridFSFindOptions)SetAllowDiskUse¶added inv1.4.0
func (f *GridFSFindOptions) SetAllowDiskUse(bbool) *GridFSFindOptions
SetAllowDiskUse sets the value for the AllowDiskUse field.
func (*GridFSFindOptions)SetBatchSize¶added inv0.1.0
func (f *GridFSFindOptions) SetBatchSize(iint32) *GridFSFindOptions
SetBatchSize sets the value for the BatchSize field.
func (*GridFSFindOptions)SetLimit¶added inv0.1.0
func (f *GridFSFindOptions) SetLimit(iint32) *GridFSFindOptions
SetLimit sets the value for the Limit field.
func (*GridFSFindOptions)SetMaxTime¶added inv0.1.0
func (f *GridFSFindOptions) SetMaxTime(dtime.Duration) *GridFSFindOptions
SetMaxTime sets the value for the MaxTime field.
NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeoutoption may be used in its place to control the amount of time that a single operation canrun before returning an error. MaxTime is ignored if Timeout is set on the client.
func (*GridFSFindOptions)SetNoCursorTimeout¶added inv0.1.0
func (f *GridFSFindOptions) SetNoCursorTimeout(bbool) *GridFSFindOptions
SetNoCursorTimeout sets the value for the NoCursorTimeout field.
func (*GridFSFindOptions)SetSkip¶added inv0.1.0
func (f *GridFSFindOptions) SetSkip(iint32) *GridFSFindOptions
SetSkip sets the value for the Skip field.
func (*GridFSFindOptions)SetSort¶added inv0.1.0
func (f *GridFSFindOptions) SetSort(sort interface{}) *GridFSFindOptions
SetSort sets the value for the Sort field.
typeIDPInfo¶added inv1.17.0
IDPInfo contains the information needed to perform OIDC authentication withan Identity Provider.
typeIndexOptions¶added inv0.2.0
type IndexOptions struct {// If true, the index will be built in the background on the server and will not block other tasks. The default// value is false.//// Deprecated: This option has been deprecated in MongoDB version 4.2.Background *bool// The length of time, in seconds, for documents to remain in the collection. The default value is 0, which means// that documents will remain in the collection until they're explicitly deleted or the collection is dropped.ExpireAfterSeconds *int32// The name of the index. The default value is "[field1]_[direction1]_[field2]_[direction2]...". For example, an// index with the specification {name: 1, age: -1} will be named "name_1_age_-1".Name *string// If true, the index will only reference documents that contain the fields specified in the index. The default is// false.Sparse *bool// Specifies the storage engine to use for the index. The value must be a document in the form// {<storage engine name>: <options>}. The default value is nil, which means that the default storage engine// will be used. This option is only applicable for MongoDB versions >= 3.0 and is ignored for previous server// versions.StorageEngine interface{}// If true, the collection will not accept insertion or update of documents where the index key value matches an// existing value in the index. The default is false.Unique *bool// The index version number, either 0 or 1.Version *int32// The language that determines the list of stop words and the rules for the stemmer and tokenizer. This option// is only applicable for text indexes and is ignored for other index types. The default value is "english".DefaultLanguage *string// The name of the field in the collection's documents that contains the override language for the document. This// option is only applicable for text indexes and is ignored for other index types. The default value is the value// of the DefaultLanguage option.LanguageOverride *string// The index version number for a text index. Seehttps://www.mongodb.com/docs/manual/core/index-text/#text-versions for// information about different version numbers.TextVersion *int32// A document that contains field and weight pairs. The weight is an integer ranging from 1 to 99,999, inclusive,// indicating the significance of the field relative to the other indexed fields in terms of the score. This option// is only applicable for text indexes and is ignored for other index types. The default value is nil, which means// that every field will have a weight of 1.Weights interface{}// The index version number for a 2D sphere index. Seehttps://www.mongodb.com/docs/manual/core/2dsphere/#dsphere-v2 for// information about different version numbers.SphereVersion *int32// The precision of the stored geohash value of the location data. This option only applies to 2D indexes and is// ignored for other index types. The value must be between 1 and 32, inclusive. The default value is 26.Bits *int32// The upper inclusive boundary for longitude and latitude values. This option is only applicable to 2D indexes and// is ignored for other index types. The default value is 180.0.Max *float64// The lower inclusive boundary for longitude and latitude values. This option is only applicable to 2D indexes and// is ignored for other index types. The default value is -180.0.Min *float64// The number of units within which to group location values. Location values that are within BucketSize units of// each other will be grouped in the same bucket. This option is only applicable to geoHaystack indexes and is// ignored for other index types. The value must be greater than 0.BucketSize *int32// A document that defines which collection documents the index should reference. This option is only valid for// MongoDB versions >= 3.2 and is ignored for previous server versions.PartialFilterExpression interface{}// The collation to use for string comparisons for the index. This option is only valid for MongoDB versions >= 3.4.// For previous server versions, the driver will return an error if this option is used.Collation *Collation// A document that defines the wildcard projection for the index.WildcardProjection interface{}// If true, the index will exist on the target collection but will not be used by the query planner when executing// operations. This option is only valid for MongoDB versions >= 4.4. The default value is false.Hidden *bool}IndexOptions represents options that can be used to configure a new index created through the IndexView.CreateOneor IndexView.CreateMany operations.
funcMergeIndexOptionsdeprecatedadded inv0.2.0
func MergeIndexOptions(opts ...*IndexOptions) *IndexOptions
MergeIndexOptions combines the given IndexOptions into a single IndexOptions in a last-one-wins fashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create asingle options struct instead.
func (*IndexOptions)SetBackgrounddeprecatedadded inv0.2.0
func (i *IndexOptions) SetBackground(backgroundbool) *IndexOptions
SetBackground sets value for the Background field.
Deprecated: This option has been deprecated in MongoDB version 4.2.
func (*IndexOptions)SetBits¶added inv0.2.0
func (i *IndexOptions) SetBits(bitsint32) *IndexOptions
SetBits sets the value for the Bits field.
func (*IndexOptions)SetBucketSize¶added inv0.2.0
func (i *IndexOptions) SetBucketSize(bucketSizeint32) *IndexOptions
SetBucketSize sets the value for the BucketSize field
func (*IndexOptions)SetCollation¶added inv0.2.0
func (i *IndexOptions) SetCollation(collation *Collation) *IndexOptions
SetCollation sets the value for the Collation field.
func (*IndexOptions)SetDefaultLanguage¶added inv0.2.0
func (i *IndexOptions) SetDefaultLanguage(languagestring) *IndexOptions
SetDefaultLanguage sets the value for the DefaultLanguage field.
func (*IndexOptions)SetExpireAfterSeconds¶added inv0.2.0
func (i *IndexOptions) SetExpireAfterSeconds(secondsint32) *IndexOptions
SetExpireAfterSeconds sets value for the ExpireAfterSeconds field.
func (*IndexOptions)SetHidden¶added inv1.4.0
func (i *IndexOptions) SetHidden(hiddenbool) *IndexOptions
SetHidden sets the value for the Hidden field.
func (*IndexOptions)SetLanguageOverride¶added inv0.2.0
func (i *IndexOptions) SetLanguageOverride(overridestring) *IndexOptions
SetLanguageOverride sets the value of the LanguageOverride field.
func (*IndexOptions)SetMax¶added inv0.2.0
func (i *IndexOptions) SetMax(maxfloat64) *IndexOptions
SetMax sets the value for the Max field.
func (*IndexOptions)SetMin¶added inv0.2.0
func (i *IndexOptions) SetMin(minfloat64) *IndexOptions
SetMin sets the value for the Min field.
func (*IndexOptions)SetName¶added inv0.2.0
func (i *IndexOptions) SetName(namestring) *IndexOptions
SetName sets the value for the Name field.
func (*IndexOptions)SetPartialFilterExpression¶added inv0.2.0
func (i *IndexOptions) SetPartialFilterExpression(expression interface{}) *IndexOptions
SetPartialFilterExpression sets the value for the PartialFilterExpression field.
func (*IndexOptions)SetSparse¶added inv0.2.0
func (i *IndexOptions) SetSparse(sparsebool) *IndexOptions
SetSparse sets the value of the Sparse field.
func (*IndexOptions)SetSphereVersion¶added inv0.2.0
func (i *IndexOptions) SetSphereVersion(versionint32) *IndexOptions
SetSphereVersion sets the value for the SphereVersion field.
func (*IndexOptions)SetStorageEngine¶added inv0.2.0
func (i *IndexOptions) SetStorageEngine(engine interface{}) *IndexOptions
SetStorageEngine sets the value for the StorageEngine field.
func (*IndexOptions)SetTextVersion¶added inv0.2.0
func (i *IndexOptions) SetTextVersion(versionint32) *IndexOptions
SetTextVersion sets the value for the TextVersion field.
func (*IndexOptions)SetUnique¶added inv0.2.0
func (i *IndexOptions) SetUnique(uniquebool) *IndexOptions
SetUnique sets the value for the Unique field.
func (*IndexOptions)SetVersion¶added inv0.2.0
func (i *IndexOptions) SetVersion(versionint32) *IndexOptions
SetVersion sets the value for the Version field.
func (*IndexOptions)SetWeights¶added inv0.2.0
func (i *IndexOptions) SetWeights(weights interface{}) *IndexOptions
SetWeights sets the value for the Weights field.
func (*IndexOptions)SetWildcardProjection¶added inv1.1.0
func (i *IndexOptions) SetWildcardProjection(wildcardProjection interface{}) *IndexOptions
SetWildcardProjection sets the value for the WildcardProjection field.
typeInsertManyOptions¶added inv0.1.0
type InsertManyOptions struct {// If true, writes executed as part of the operation will opt out of document-level validation on the server. This// option is valid for MongoDB versions >= 3.2 and is ignored for previous server versions. The default value is// false. Seehttps://www.mongodb.com/docs/manual/core/schema-validation/ for more information about document// validation.BypassDocumentValidation *bool// A string or document that will be included in server logs, profiling logs, and currentOp queries to help trace// the operation. The default value is nil, which means that no comment will be included in the logs.Comment interface{}// If true, no writes will be executed after one fails. The default value is true.Ordered *bool// If true, the server accepts empty Timestamp as a literal rather than replacing it with the current time.//// Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any// release.BypassEmptyTsReplacement *bool}InsertManyOptions represents options that can be used to configure an InsertMany operation.
funcInsertMany¶added inv0.1.0
func InsertMany() *InsertManyOptions
InsertMany creates a new InsertManyOptions instance.
funcMergeInsertManyOptionsdeprecatedadded inv0.1.0
func MergeInsertManyOptions(opts ...*InsertManyOptions) *InsertManyOptions
MergeInsertManyOptions combines the given InsertManyOptions instances into a single InsertManyOptions in a last onewins fashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create asingle options struct instead.
func (*InsertManyOptions)SetBypassDocumentValidation¶added inv0.1.0
func (imo *InsertManyOptions) SetBypassDocumentValidation(bbool) *InsertManyOptions
SetBypassDocumentValidation sets the value for the BypassDocumentValidation field.
func (*InsertManyOptions)SetComment¶added inv1.10.0
func (imo *InsertManyOptions) SetComment(comment interface{}) *InsertManyOptions
SetComment sets the value for the Comment field.
func (*InsertManyOptions)SetOrdered¶added inv0.1.0
func (imo *InsertManyOptions) SetOrdered(bbool) *InsertManyOptions
SetOrdered sets the value for the Ordered field.
typeInsertOneOptions¶added inv0.1.0
type InsertOneOptions struct {// If true, writes executed as part of the operation will opt out of document-level validation on the server. This// option is valid for MongoDB versions >= 3.2 and is ignored for previous server versions. The default value is// false. Seehttps://www.mongodb.com/docs/manual/core/schema-validation/ for more information about document// validation.BypassDocumentValidation *bool// A string or document that will be included in server logs, profiling logs, and currentOp queries to help trace// the operation. The default value is nil, which means that no comment will be included in the logs.Comment interface{}// If true, the server accepts empty Timestamp as a literal rather than replacing it with the current time.//// Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any// release.BypassEmptyTsReplacement *bool}InsertOneOptions represents options that can be used to configure an InsertOne operation.
funcInsertOne¶added inv0.1.0
func InsertOne() *InsertOneOptions
InsertOne creates a new InsertOneOptions instance.
funcMergeInsertOneOptionsdeprecatedadded inv0.1.0
func MergeInsertOneOptions(opts ...*InsertOneOptions) *InsertOneOptions
MergeInsertOneOptions combines the given InsertOneOptions instances into a single InsertOneOptions in a last-one-winsfashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create asingle options struct instead.
func (*InsertOneOptions)SetBypassDocumentValidation¶added inv0.1.0
func (ioo *InsertOneOptions) SetBypassDocumentValidation(bbool) *InsertOneOptions
SetBypassDocumentValidation sets the value for the BypassDocumentValidation field.
func (*InsertOneOptions)SetComment¶added inv1.10.0
func (ioo *InsertOneOptions) SetComment(comment interface{}) *InsertOneOptions
SetComment sets the value for the Comment field.
typeListCollectionsOptions¶added inv0.1.0
type ListCollectionsOptions struct {// If true, each collection document will only contain a field for the collection name. The default value is false.NameOnly *bool// The maximum number of documents to be included in each batch returned by the server.BatchSize *int32// If true, and NameOnly is true, limits the documents returned to only contain collections the user is authorized to use. The default value// is false. This option is only valid for MongoDB server versions >= 4.0. Server versions < 4.0 ignore this option.AuthorizedCollections *bool}ListCollectionsOptions represents options that can be used to configure a ListCollections operation.
funcListCollections¶added inv0.1.0
func ListCollections() *ListCollectionsOptions
ListCollections creates a new ListCollectionsOptions instance.
funcMergeListCollectionsOptionsdeprecatedadded inv0.1.0
func MergeListCollectionsOptions(opts ...*ListCollectionsOptions) *ListCollectionsOptions
MergeListCollectionsOptions combines the given ListCollectionsOptions instances into a single *ListCollectionsOptionsin a last-one-wins fashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create asingle options struct instead.
func (*ListCollectionsOptions)SetAuthorizedCollections¶added inv1.9.0
func (lc *ListCollectionsOptions) SetAuthorizedCollections(bbool) *ListCollectionsOptions
SetAuthorizedCollections sets the value for the AuthorizedCollections field. This option is only valid for MongoDB server versions >= 4.0. Serverversions < 4.0 ignore this option.
func (*ListCollectionsOptions)SetBatchSize¶added inv1.5.0
func (lc *ListCollectionsOptions) SetBatchSize(sizeint32) *ListCollectionsOptions
SetBatchSize sets the value for the BatchSize field.
func (*ListCollectionsOptions)SetNameOnly¶added inv0.1.0
func (lc *ListCollectionsOptions) SetNameOnly(bbool) *ListCollectionsOptions
SetNameOnly sets the value for the NameOnly field.
typeListDatabasesOptions¶added inv0.1.0
type ListDatabasesOptions struct {// If true, only the Name field of the returned DatabaseSpecification objects will be populated. The default value// is false.NameOnly *bool// If true, only the databases which the user is authorized to see will be returned. For more information about// the behavior of this option, seehttps://www.mongodb.com/docs/manual/reference/privilege-actions/#find. The default// value is true.AuthorizedDatabases *bool}ListDatabasesOptions represents options that can be used to configure a ListDatabases operation.
funcListDatabases¶added inv0.1.0
func ListDatabases() *ListDatabasesOptions
ListDatabases creates a new ListDatabasesOptions instance.
funcMergeListDatabasesOptionsdeprecatedadded inv0.1.0
func MergeListDatabasesOptions(opts ...*ListDatabasesOptions) *ListDatabasesOptions
MergeListDatabasesOptions combines the given ListDatabasesOptions instances into a single *ListDatabasesOptions in alast-one-wins fashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create asingle options struct instead.
func (*ListDatabasesOptions)SetAuthorizedDatabases¶added inv1.4.0
func (ld *ListDatabasesOptions) SetAuthorizedDatabases(bbool) *ListDatabasesOptions
SetAuthorizedDatabases sets the value for the AuthorizedDatabases field.
func (*ListDatabasesOptions)SetNameOnly¶added inv0.1.0
func (ld *ListDatabasesOptions) SetNameOnly(bbool) *ListDatabasesOptions
SetNameOnly sets the value for the NameOnly field.
typeListIndexesOptions¶added inv0.1.0
type ListIndexesOptions struct {// The maximum number of documents to be included in each batch returned by the server.BatchSize *int32// The maximum amount of time that the query can run on the server. The default value is nil, meaning that there// is no time limit for query execution.//// NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeout option may be used// in its place to control the amount of time that a single operation can run before returning an error. MaxTime// is ignored if Timeout is set on the client.MaxTime *time.Duration}ListIndexesOptions represents options that can be used to configure an IndexView.List operation.
funcListIndexes¶added inv0.1.0
func ListIndexes() *ListIndexesOptions
ListIndexes creates a new ListIndexesOptions instance.
funcMergeListIndexesOptionsdeprecatedadded inv0.1.0
func MergeListIndexesOptions(opts ...*ListIndexesOptions) *ListIndexesOptions
MergeListIndexesOptions combines the given ListIndexesOptions instances into a single *ListIndexesOptions in alast-one-wins fashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create asingle options struct instead.
func (*ListIndexesOptions)SetBatchSize¶added inv0.1.0
func (l *ListIndexesOptions) SetBatchSize(iint32) *ListIndexesOptions
SetBatchSize sets the value for the BatchSize field.
func (*ListIndexesOptions)SetMaxTime¶added inv0.1.0
func (l *ListIndexesOptions) SetMaxTime(dtime.Duration) *ListIndexesOptions
SetMaxTime sets the value for the MaxTime field.
NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeoutoption may be used in its place to control the amount of time that a single operation canrun before returning an error. MaxTime is ignored if Timeout is set on the client.
typeListSearchIndexesOptions¶added inv1.13.0
type ListSearchIndexesOptions struct {AggregateOpts *AggregateOptions}ListSearchIndexesOptions represents options that can be used to configure a SearchIndexView.List operation.
typeLogComponent¶added inv1.12.0
type LogComponentint
LogComponent is an enumeration representing the "components" which can belogged against. A LogLevel can be configured on a per-component basis.
const (// LogComponentAll enables logging for all components.LogComponentAllLogComponent =LogComponent(logger.ComponentAll)// LogComponentCommand enables command monitor logging.LogComponentCommandLogComponent =LogComponent(logger.ComponentCommand)// LogComponentTopology enables topology logging.LogComponentTopologyLogComponent =LogComponent(logger.ComponentTopology)// LogComponentServerSelection enables server selection logging.LogComponentServerSelectionLogComponent =LogComponent(logger.ComponentServerSelection)// LogComponentConnection enables connection services logging.LogComponentConnectionLogComponent =LogComponent(logger.ComponentConnection))
typeLogLevel¶added inv1.12.0
type LogLevelint
LogLevel is an enumeration representing the supported log severity levels.
const (// LogLevelInfo enables logging of informational messages. These logs// are high-level information about normal driver behavior.LogLevelInfoLogLevel =LogLevel(logger.LevelInfo)// LogLevelDebug enables logging of debug messages. These logs can be// voluminous and are intended for detailed information that may be// helpful when debugging an application.LogLevelDebugLogLevel =LogLevel(logger.LevelDebug))
typeLogSink¶added inv1.12.0
type LogSink interface {// Info logs a non-error message with the given key/value pairs. This// method will only be called if the provided level has been defined// for a component in the LoggerOptions.//// Here are the following level mappings for V = "Verbosity"://// - V(0): off// - V(1): informational// - V(2): debugging//// This level mapping is taken from the go-logr/logr library// specifications, specifically://// "Level V(0) is the default, and logger.V(0).Info() has the same// meaning as logger.Info()."Info(levelint, messagestring, keysAndValues ...interface{})// Error logs an error message with the given key/value pairsError(errerror, messagestring, keysAndValues ...interface{})}LogSink is an interface that can be implemented to provide a custom sink forthe driver's logs.
typeLoggerOptions¶added inv1.12.0
type LoggerOptions struct {// ComponentLevels is a map of LogComponent to LogLevel. The LogLevel// for a given LogComponent will be used to determine if a log message// should be logged.ComponentLevels map[LogComponent]LogLevel// Sink is the LogSink that will be used to log messages. If this is// nil, the driver will use the standard logging library.SinkLogSink// MaxDocumentLength is the maximum length of a document to be logged.// If the underlying document is larger than this value, it will be// truncated and appended with an ellipses "...".MaxDocumentLengthuint}LoggerOptions represent options used to configure Logging in the Go Driver.
func (*LoggerOptions)SetComponentLevel¶added inv1.12.0
func (opts *LoggerOptions) SetComponentLevel(componentLogComponent, levelLogLevel) *LoggerOptions
SetComponentLevel sets the LogLevel value for a LogComponent.
func (*LoggerOptions)SetMaxDocumentLength¶added inv1.12.0
func (opts *LoggerOptions) SetMaxDocumentLength(maxDocumentLengthuint) *LoggerOptions
SetMaxDocumentLength sets the maximum length of a document to be logged.
func (*LoggerOptions)SetSink¶added inv1.12.0
func (opts *LoggerOptions) SetSink(sinkLogSink) *LoggerOptions
SetSink sets the LogSink to use for logging.
typeMarshalErrordeprecatedadded inv0.1.0
type MarshalError struct {Value interface{}Errerror}MarshalError is returned when attempting to transform a value into a documentresults in an error.
Deprecated: MarshalError is unused and will be removed in Go Driver 2.0.
func (MarshalError)Errordeprecatedadded inv0.1.0
func (meMarshalError) Error()string
Error implements the error interface.
Deprecated: MarshalError is unused and will be removed in Go Driver 2.0.
typeNameOptions¶added inv0.1.0
type NameOptions struct {// Specifies the revision of the file to retrieve. 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.//// The default value is -1Revision *int32}NameOptions represents options that can be used to configure a GridFS DownloadByName operation.
funcGridFSName¶added inv0.1.0
func GridFSName() *NameOptions
GridFSName creates a new NameOptions instance.
funcMergeNameOptionsdeprecatedadded inv0.1.0
func MergeNameOptions(opts ...*NameOptions) *NameOptions
MergeNameOptions combines the given NameOptions instances into a single *NameOptions in a last-one-wins fashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create asingle options struct instead.
func (*NameOptions)SetRevision¶added inv0.1.0
func (n *NameOptions) SetRevision(rint32) *NameOptions
SetRevision sets the value for the Revision field.
typeOIDCCallback¶added inv1.17.0
type OIDCCallback func(context.Context, *OIDCArgs) (*OIDCCredential,error)
OIDCCallback is the type for both Human and Machine Callback flows.RefreshToken will always be nil in the OIDCArgs for the Machine flow.
typeOIDCCredential¶added inv1.17.0
OIDCCredential contains the access token and refresh token.
typeRangeOptions¶added inv1.12.0
type RangeOptions struct {Min *bson.RawValueMax *bson.RawValueSparsity *int64TrimFactor *int32Precision *int32}RangeOptions specifies index options for a Queryable Encryption field supporting "range" queries.
func (*RangeOptions)SetMax¶added inv1.12.0
func (ro *RangeOptions) SetMax(maxbson.RawValue) *RangeOptions
SetMax sets the range index maximum value.
func (*RangeOptions)SetMin¶added inv1.12.0
func (ro *RangeOptions) SetMin(minbson.RawValue) *RangeOptions
SetMin sets the range index minimum value.
func (*RangeOptions)SetPrecision¶added inv1.12.0
func (ro *RangeOptions) SetPrecision(precisionint32) *RangeOptions
SetPrecision sets the range index precision.
func (*RangeOptions)SetSparsity¶added inv1.12.0
func (ro *RangeOptions) SetSparsity(sparsityint64) *RangeOptions
SetSparsity sets the range index sparsity.
func (*RangeOptions)SetTrimFactor¶added inv1.17.0
func (ro *RangeOptions) SetTrimFactor(trimFactorint32) *RangeOptions
SetTrimFactor sets the range index trim factor.
typeReplaceOptions¶added inv0.1.0
type ReplaceOptions struct {// If true, writes executed as part of the operation will opt out of document-level validation on the server. This// option is valid for MongoDB versions >= 3.2 and is ignored for previous server versions. The default value is// false. Seehttps://www.mongodb.com/docs/manual/core/schema-validation/ for more information about document// validation.BypassDocumentValidation *bool// Specifies a collation to use for string comparisons during the operation. This option is only valid for MongoDB// versions >= 3.4. For previous server versions, the driver will return an error if this option is used. The// default value is nil, which means the default collation of the collection will be used.Collation *Collation// A string or document that will be included in server logs, profiling logs, and currentOp queries to help trace// the operation. The default value is nil, which means that no comment will be included in the logs.Comment interface{}// The index to use for the operation. This should either be the index name as a string or the index specification// as a document. This option is only valid for MongoDB versions >= 4.2. Server versions >= 3.4 will return an error// if this option is specified. For server versions < 3.4, the driver will return a client-side error if this option// is specified. The driver will return an error if this option is specified during an unacknowledged write// operation. The driver will return an error if the hint parameter is a multi-key map. The default value is nil,// which means that no hint will be sent.Hint interface{}// If true, a new document will be inserted if the filter does not match any documents in the collection. The// default value is false.Upsert *bool// Specifies parameters for the aggregate expression. This option is only valid for MongoDB versions >= 5.0. Older// servers will report an error for using this option. This must be a document mapping parameter names to values.// Values must be constant or closed expressions that do not reference document fields. Parameters can then be// accessed as variables in an aggregate expression context (e.g. "$$var").Let interface{}// If true, the server accepts empty Timestamp as a literal rather than replacing it with the current time.//// Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any// release.BypassEmptyTsReplacement *bool}ReplaceOptions represents options that can be used to configure a ReplaceOne operation.
funcMergeReplaceOptionsdeprecatedadded inv0.1.0
func MergeReplaceOptions(opts ...*ReplaceOptions) *ReplaceOptions
MergeReplaceOptions combines the given ReplaceOptions instances into a single ReplaceOptions in a last-one-winsfashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create asingle options struct instead.
funcReplace¶added inv0.1.0
func Replace() *ReplaceOptions
Replace creates a new ReplaceOptions instance.
func (*ReplaceOptions)SetBypassDocumentValidation¶added inv0.1.0
func (ro *ReplaceOptions) SetBypassDocumentValidation(bbool) *ReplaceOptions
SetBypassDocumentValidation sets the value for the BypassDocumentValidation field.
func (*ReplaceOptions)SetCollation¶added inv0.1.0
func (ro *ReplaceOptions) SetCollation(c *Collation) *ReplaceOptions
SetCollation sets the value for the Collation field.
func (*ReplaceOptions)SetComment¶added inv1.10.0
func (ro *ReplaceOptions) SetComment(comment interface{}) *ReplaceOptions
SetComment sets the value for the Comment field.
func (*ReplaceOptions)SetHint¶added inv1.4.0
func (ro *ReplaceOptions) SetHint(h interface{}) *ReplaceOptions
SetHint sets the value for the Hint field.
func (*ReplaceOptions)SetLet¶added inv1.9.0
func (ro *ReplaceOptions) SetLet(l interface{}) *ReplaceOptions
SetLet sets the value for the Let field.
func (*ReplaceOptions)SetUpsert¶added inv0.1.0
func (ro *ReplaceOptions) SetUpsert(bbool) *ReplaceOptions
SetUpsert sets the value for the Upsert field.
typeReturnDocument¶
type ReturnDocumentint8
ReturnDocument specifies whether a findAndUpdate operation should return the document as it wasbefore the update or as it is after the update.
const (// Before specifies that findAndUpdate should return the document as it was before the update.BeforeReturnDocument =iota// After specifies that findAndUpdate should return the document as it is after the update.After)
typeRewrapManyDataKeyOptions¶added inv1.10.0
type RewrapManyDataKeyOptions struct {// Provider identifies the new KMS provider. If omitted, encrypting uses the current KMS provider.Provider *string// MasterKey identifies the new masterKey. If omitted, rewraps with the current masterKey.MasterKey interface{}}RewrapManyDataKeyOptions represents all possible options used to decrypt and encrypt all matching data keys with apossibly new masterKey.
funcMergeRewrapManyDataKeyOptionsdeprecatedadded inv1.10.0
func MergeRewrapManyDataKeyOptions(opts ...*RewrapManyDataKeyOptions) *RewrapManyDataKeyOptions
MergeRewrapManyDataKeyOptions combines the given RewrapManyDataKeyOptions instances into a singleRewrapManyDataKeyOptions in a last one wins fashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create asingle options struct instead.
funcRewrapManyDataKey¶added inv1.10.0
func RewrapManyDataKey() *RewrapManyDataKeyOptions
RewrapManyDataKey creates a new RewrapManyDataKeyOptions instance.
func (*RewrapManyDataKeyOptions)SetMasterKey¶added inv1.10.0
func (rmdko *RewrapManyDataKeyOptions) SetMasterKey(masterKey interface{}) *RewrapManyDataKeyOptions
SetMasterKey sets the value for the MasterKey field.
func (*RewrapManyDataKeyOptions)SetProvider¶added inv1.10.0
func (rmdko *RewrapManyDataKeyOptions) SetProvider(providerstring) *RewrapManyDataKeyOptions
SetProvider sets the value for the Provider field.
typeRunCmdOptions¶added inv0.1.0
type RunCmdOptions struct {// The read preference to use for the operation. The default value is nil, which means that the primary read// preference will be used.ReadPreference *readpref.ReadPref}RunCmdOptions represents options that can be used to configure a RunCommand operation.
funcMergeRunCmdOptionsdeprecatedadded inv0.1.0
func MergeRunCmdOptions(opts ...*RunCmdOptions) *RunCmdOptions
MergeRunCmdOptions combines the given RunCmdOptions instances into one *RunCmdOptions in a last-one-wins fashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create asingle options struct instead.
func (*RunCmdOptions)SetReadPreference¶added inv0.1.0
func (rc *RunCmdOptions) SetReadPreference(rp *readpref.ReadPref) *RunCmdOptions
SetReadPreference sets value for the ReadPreference field.
typeSearchIndexesOptions¶added inv1.13.0
SearchIndexesOptions represents options that can be used to configure a SearchIndexView.
funcSearchIndexes¶added inv1.13.0
func SearchIndexes() *SearchIndexesOptions
SearchIndexes creates a new SearchIndexesOptions instance.
func (*SearchIndexesOptions)SetName¶added inv1.13.0
func (sio *SearchIndexesOptions) SetName(namestring) *SearchIndexesOptions
SetName sets the value for the Name field.
func (*SearchIndexesOptions)SetType¶added inv1.16.0
func (sio *SearchIndexesOptions) SetType(typstring) *SearchIndexesOptions
SetType sets the value for the Type field.
typeServerAPIOptions¶added inv1.6.0
type ServerAPIOptions struct {ServerAPIVersionServerAPIVersionStrict *boolDeprecationErrors *bool}ServerAPIOptions represents options used to configure the API version sent to the serverwhen running commands.
Sending a specified server API version causes the server to behave in a manner compatible with thatAPI version. It also causes the driver to behave in a manner compatible with the driver’s behavior asof the release when the driver first started to support the specified server API version.
The user must specify a ServerAPIVersion if including ServerAPIOptions in their client. That versionmust also be currently supported by the driver. This version of the driver supports API version "1".
funcServerAPI¶added inv1.6.0
func ServerAPI(serverAPIVersionServerAPIVersion) *ServerAPIOptions
ServerAPI creates a new ServerAPIOptions configured with the provided serverAPIversion.
func (*ServerAPIOptions)SetDeprecationErrors¶added inv1.6.0
func (s *ServerAPIOptions) SetDeprecationErrors(deprecationErrorsbool) *ServerAPIOptions
SetDeprecationErrors specifies whether the server should return errors for deprecated features.
func (*ServerAPIOptions)SetStrict¶added inv1.6.0
func (s *ServerAPIOptions) SetStrict(strictbool) *ServerAPIOptions
SetStrict specifies whether the server should return errors for features that are not part of the API version.
typeServerAPIVersion¶added inv1.6.0
type ServerAPIVersionstring
ServerAPIVersion represents an API version that can be used in ServerAPIOptions.
const (// ServerAPIVersion1 is the first API version.ServerAPIVersion1ServerAPIVersion = "1")
func (ServerAPIVersion)Validate¶added inv1.6.0
func (savServerAPIVersion) Validate()error
Validate determines if the provided ServerAPIVersion is currently supported by the driver.
typeSessionOptions¶added inv0.1.0
type SessionOptions struct {// If true, causal consistency will be enabled for the session. This option cannot be set to true if Snapshot is// set to true. The default value is true unless Snapshot is set to true. See//https://www.mongodb.com/docs/manual/core/read-isolation-consistency-recency/#sessions for more information.CausalConsistency *bool// The default read concern for transactions started in the session. The default value is nil, which means that// the read concern of the client used to start the session will be used.DefaultReadConcern *readconcern.ReadConcern// The default read preference for transactions started in the session. The default value is nil, which means that// the read preference of the client used to start the session will be used.DefaultReadPreference *readpref.ReadPref// The default write concern for transactions started in the session. The default value is nil, which means that// the write concern of the client used to start the session will be used.DefaultWriteConcern *writeconcern.WriteConcern// The default maximum amount of time that a CommitTransaction operation executed in the session can run on the// server. The default value is nil, which means that that there is no time limit for execution.//// NOTE(benjirewis): DefaultMaxCommitTime will be deprecated in a future release. The more general Timeout option// may be used in its place to control the amount of time that a single operation can run before returning an// error. DefaultMaxCommitTime is ignored if Timeout is set on the client.DefaultMaxCommitTime *time.Duration// If true, all read operations performed with this session will be read from the same snapshot. This option cannot// be set to true if CausalConsistency is set to true. Transactions and write operations are not allowed on// snapshot sessions and will error. The default value is false.Snapshot *bool}SessionOptions represents options that can be used to configure a Session.
funcMergeSessionOptionsdeprecatedadded inv0.1.0
func MergeSessionOptions(opts ...*SessionOptions) *SessionOptions
MergeSessionOptions combines the given SessionOptions instances into a single SessionOptions in a last-one-winsfashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create asingle options struct instead.
funcSession¶added inv0.1.0
func Session() *SessionOptions
Session creates a new SessionOptions instance.
func (*SessionOptions)SetCausalConsistency¶added inv0.1.0
func (s *SessionOptions) SetCausalConsistency(bbool) *SessionOptions
SetCausalConsistency sets the value for the CausalConsistency field.
func (*SessionOptions)SetDefaultMaxCommitTime¶added inv1.1.0
func (s *SessionOptions) SetDefaultMaxCommitTime(mct *time.Duration) *SessionOptions
SetDefaultMaxCommitTime sets the value for the DefaultMaxCommitTime field.
NOTE(benjirewis): DefaultMaxCommitTime will be deprecated in a future release. The moregeneral Timeout option may be used in its place to control the amount of time that asingle operation can run before returning an error. DefaultMaxCommitTime is ignored ifTimeout is set on the client.
func (*SessionOptions)SetDefaultReadConcern¶added inv0.1.0
func (s *SessionOptions) SetDefaultReadConcern(rc *readconcern.ReadConcern) *SessionOptions
SetDefaultReadConcern sets the value for the DefaultReadConcern field.
func (*SessionOptions)SetDefaultReadPreference¶added inv0.1.0
func (s *SessionOptions) SetDefaultReadPreference(rp *readpref.ReadPref) *SessionOptions
SetDefaultReadPreference sets the value for the DefaultReadPreference field.
func (*SessionOptions)SetDefaultWriteConcern¶added inv0.1.0
func (s *SessionOptions) SetDefaultWriteConcern(wc *writeconcern.WriteConcern) *SessionOptions
SetDefaultWriteConcern sets the value for the DefaultWriteConcern field.
func (*SessionOptions)SetSnapshot¶added inv1.7.0
func (s *SessionOptions) SetSnapshot(bbool) *SessionOptions
SetSnapshot sets the value for the Snapshot field.
typeTimeSeriesOptions¶added inv1.6.0
type TimeSeriesOptions struct {// TimeField is the top-level field to be used for time. Inserted documents must have this field,// and the field must be of the BSON UTC datetime type (0x9).TimeFieldstring// MetaField is the name of the top-level field describing the series. This field is used to group// related data and may be of any BSON type, except for array. This name may not be the same// as the TimeField or _id. This field is optional.MetaField *string// Granularity is the granularity of time-series data. Allowed granularity options are// "seconds", "minutes" and "hours". This field is optional.Granularity *string// BucketMaxSpan is the maximum range of time values for a bucket. The// time.Duration is rounded down to the nearest second and applied as// the command option: "bucketRoundingSeconds". This field is optional.BucketMaxSpan *time.Duration// BucketRounding is used to determine the minimum time boundary when// opening a new bucket by rounding the first timestamp down to the next// multiple of this value. The time.Duration is rounded down to the// nearest second and applied as the command option:// "bucketRoundingSeconds". This field is optional.BucketRounding *time.Duration}TimeSeriesOptions specifies options on a time-series collection.
funcTimeSeries¶added inv1.6.0
func TimeSeries() *TimeSeriesOptions
TimeSeries creates a new TimeSeriesOptions instance.
func (*TimeSeriesOptions)SetBucketMaxSpan¶added inv1.12.0
func (tso *TimeSeriesOptions) SetBucketMaxSpan(durtime.Duration) *TimeSeriesOptions
SetBucketMaxSpan sets the value for BucketMaxSpan.
func (*TimeSeriesOptions)SetBucketRounding¶added inv1.12.0
func (tso *TimeSeriesOptions) SetBucketRounding(durtime.Duration) *TimeSeriesOptions
SetBucketRounding sets the value for BucketRounding.
func (*TimeSeriesOptions)SetGranularity¶added inv1.6.0
func (tso *TimeSeriesOptions) SetGranularity(granularitystring) *TimeSeriesOptions
SetGranularity sets the value for Granularity.
func (*TimeSeriesOptions)SetMetaField¶added inv1.6.0
func (tso *TimeSeriesOptions) SetMetaField(metaFieldstring) *TimeSeriesOptions
SetMetaField sets the value for the MetaField.
func (*TimeSeriesOptions)SetTimeField¶added inv1.6.0
func (tso *TimeSeriesOptions) SetTimeField(timeFieldstring) *TimeSeriesOptions
SetTimeField sets the value for the TimeField.
typeTransactionOptions¶added inv0.1.0
type TransactionOptions struct {// The read concern for operations in the transaction. The default value is nil, which means that the default// read concern of the session used to start the transaction will be used.ReadConcern *readconcern.ReadConcern// The read preference for operations in the transaction. The default value is nil, which means that the default// read preference of the session used to start the transaction will be used.ReadPreference *readpref.ReadPref// The write concern for operations in the transaction. The default value is nil, which means that the default// write concern of the session used to start the transaction will be used.WriteConcern *writeconcern.WriteConcern// The maximum amount of time that a CommitTransaction operation can executed in the transaction can run on the// server. The default value is nil, which means that the default maximum commit time of the session used to// start the transaction will be used.//// NOTE(benjirewis): MaxCommitTime will be deprecated in a future release. The more general Timeout option may// be used in its place to control the amount of time that a single operation can run before returning an error.// MaxCommitTime is ignored if Timeout is set on the client.MaxCommitTime *time.Duration}TransactionOptions represents options that can be used to configure a transaction.
funcMergeTransactionOptionsdeprecatedadded inv0.1.0
func MergeTransactionOptions(opts ...*TransactionOptions) *TransactionOptions
MergeTransactionOptions combines the given TransactionOptions instances into a single TransactionOptions in alast-one-wins fashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create asingle options struct instead.
funcTransaction¶added inv0.1.0
func Transaction() *TransactionOptions
Transaction creates a new TransactionOptions instance.
func (*TransactionOptions)SetMaxCommitTime¶added inv1.1.0
func (t *TransactionOptions) SetMaxCommitTime(mct *time.Duration) *TransactionOptions
SetMaxCommitTime sets the value for the MaxCommitTime field.
NOTE(benjirewis): MaxCommitTime will be deprecated in a future release. The more general Timeoutoption may be used in its place to control the amount of time that a single operation can run beforereturning an error. MaxCommitTime is ignored if Timeout is set on the client.
func (*TransactionOptions)SetReadConcern¶added inv0.1.0
func (t *TransactionOptions) SetReadConcern(rc *readconcern.ReadConcern) *TransactionOptions
SetReadConcern sets the value for the ReadConcern field.
func (*TransactionOptions)SetReadPreference¶added inv0.1.0
func (t *TransactionOptions) SetReadPreference(rp *readpref.ReadPref) *TransactionOptions
SetReadPreference sets the value for the ReadPreference field.
func (*TransactionOptions)SetWriteConcern¶added inv0.1.0
func (t *TransactionOptions) SetWriteConcern(wc *writeconcern.WriteConcern) *TransactionOptions
SetWriteConcern sets the value for the WriteConcern field.
typeUpdateOptions¶added inv0.1.0
type UpdateOptions struct {// A set of filters specifying to which array elements an update should apply. This option is only valid for MongoDB// versions >= 3.6. For previous server versions, the driver will return an error if this option is used. The// default value is nil, which means the update will apply to all array elements.ArrayFilters *ArrayFilters// If true, writes executed as part of the operation will opt out of document-level validation on the server. This// option is valid for MongoDB versions >= 3.2 and is ignored for previous server versions. The default value is// false. Seehttps://www.mongodb.com/docs/manual/core/schema-validation/ for more information about document// validation.BypassDocumentValidation *bool// Specifies a collation to use for string comparisons during the operation. This option is only valid for MongoDB// versions >= 3.4. For previous server versions, the driver will return an error if this option is used. The// default value is nil, which means the default collation of the collection will be used.Collation *Collation// A string or document that will be included in server logs, profiling logs, and currentOp queries to help trace// the operation. The default value is nil, which means that no comment will be included in the logs.Comment interface{}// The index to use for the operation. This should either be the index name as a string or the index specification// as a document. This option is only valid for MongoDB versions >= 4.2. Server versions >= 3.4 will return an error// if this option is specified. For server versions < 3.4, the driver will return a client-side error if this option// is specified. The driver will return an error if this option is specified during an unacknowledged write// operation. The driver will return an error if the hint parameter is a multi-key map. The default value is nil,// which means that no hint will be sent.Hint interface{}// If true, a new document will be inserted if the filter does not match any documents in the collection. The// default value is false.Upsert *bool// Specifies parameters for the update expression. This option is only valid for MongoDB versions >= 5.0. Older// servers will report an error for using this option. This must be a document mapping parameter names to values.// Values must be constant or closed expressions that do not reference document fields. Parameters can then be// accessed as variables in an aggregate expression context (e.g. "$$var").Let interface{}// If true, the server accepts empty Timestamp as a literal rather than replacing it with the current time.//// Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any// release.BypassEmptyTsReplacement *bool}UpdateOptions represents options that can be used to configure UpdateOne and UpdateMany operations.
funcMergeUpdateOptionsdeprecatedadded inv0.1.0
func MergeUpdateOptions(opts ...*UpdateOptions) *UpdateOptions
MergeUpdateOptions combines the given UpdateOptions instances into a single UpdateOptions in a last-one-wins fashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create asingle options struct instead.
func (*UpdateOptions)SetArrayFilters¶added inv0.1.0
func (uo *UpdateOptions) SetArrayFilters(afArrayFilters) *UpdateOptions
SetArrayFilters sets the value for the ArrayFilters field.
func (*UpdateOptions)SetBypassDocumentValidation¶added inv0.1.0
func (uo *UpdateOptions) SetBypassDocumentValidation(bbool) *UpdateOptions
SetBypassDocumentValidation sets the value for the BypassDocumentValidation field.
func (*UpdateOptions)SetCollation¶added inv0.1.0
func (uo *UpdateOptions) SetCollation(c *Collation) *UpdateOptions
SetCollation sets the value for the Collation field.
func (*UpdateOptions)SetComment¶added inv1.10.0
func (uo *UpdateOptions) SetComment(comment interface{}) *UpdateOptions
SetComment sets the value for the Comment field.
func (*UpdateOptions)SetHint¶added inv1.4.0
func (uo *UpdateOptions) SetHint(h interface{}) *UpdateOptions
SetHint sets the value for the Hint field.
func (*UpdateOptions)SetLet¶added inv1.9.0
func (uo *UpdateOptions) SetLet(l interface{}) *UpdateOptions
SetLet sets the value for the Let field.
func (*UpdateOptions)SetUpsert¶added inv0.1.0
func (uo *UpdateOptions) SetUpsert(bbool) *UpdateOptions
SetUpsert sets the value for the Upsert field.
typeUpdateSearchIndexOptions¶added inv1.13.0
type UpdateSearchIndexOptions struct {}UpdateSearchIndexOptions represents options that can be used to configure a SearchIndexView.UpdateOne operation.
typeUploadOptions¶added inv0.1.0
type UploadOptions struct {// The number of bytes in each chunk in the bucket. The default value is DefaultChunkSize (255 KiB).ChunkSizeBytes *int32// Additional application data that will be stored in the "metadata" field of the document in the files collection.// The default value is nil, which means that the document in the files collection will not contain a "metadata"// field.Metadata interface{}// The BSON registry to use for converting filters to BSON documents. The default value is bson.DefaultRegistry.Registry *bsoncodec.Registry}UploadOptions represents options that can be used to configure a GridFS upload operation.
funcGridFSUpload¶added inv0.1.0
func GridFSUpload() *UploadOptions
GridFSUpload creates a new UploadOptions instance.
funcMergeUploadOptionsdeprecatedadded inv0.1.0
func MergeUploadOptions(opts ...*UploadOptions) *UploadOptions
MergeUploadOptions combines the given UploadOptions instances into a single UploadOptions in a last-one-wins fashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create asingle options struct instead.
func (*UploadOptions)SetChunkSizeBytes¶added inv0.1.0
func (u *UploadOptions) SetChunkSizeBytes(iint32) *UploadOptions
SetChunkSizeBytes sets the value for the ChunkSize field.
func (*UploadOptions)SetMetadata¶added inv0.1.0
func (u *UploadOptions) SetMetadata(doc interface{}) *UploadOptions
SetMetadata sets the value for the Metadata field.
Source Files¶
- aggregateoptions.go
- autoencryptionoptions.go
- bulkwriteoptions.go
- changestreamoptions.go
- clientencryptionoptions.go
- clientoptions.go
- collectionoptions.go
- countoptions.go
- createcollectionoptions.go
- datakeyoptions.go
- dboptions.go
- deleteoptions.go
- distinctoptions.go
- doc.go
- encryptoptions.go
- estimatedcountoptions.go
- findoptions.go
- gridfsoptions.go
- indexoptions.go
- insertoptions.go
- listcollectionsoptions.go
- listdatabasesoptions.go
- loggeroptions.go
- mongooptions.go
- replaceoptions.go
- rewrapdatakeyoptions.go
- runcmdoptions.go
- searchindexoptions.go
- serverapioptions.go
- sessionoptions.go
- transactionoptions.go
- updateoptions.go