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
- type AggregateOptionsBuilder
- func (ao *AggregateOptionsBuilder) List() []func(*AggregateOptions) error
- func (ao *AggregateOptionsBuilder) SetAllowDiskUse(b bool) *AggregateOptionsBuilder
- func (ao *AggregateOptionsBuilder) SetBatchSize(i int32) *AggregateOptionsBuilder
- func (ao *AggregateOptionsBuilder) SetBypassDocumentValidation(b bool) *AggregateOptionsBuilder
- func (ao *AggregateOptionsBuilder) SetCollation(c *Collation) *AggregateOptionsBuilder
- func (ao *AggregateOptionsBuilder) SetComment(comment interface{}) *AggregateOptionsBuilder
- func (ao *AggregateOptionsBuilder) SetCustom(c bson.M) *AggregateOptionsBuilder
- func (ao *AggregateOptionsBuilder) SetHint(h interface{}) *AggregateOptionsBuilder
- func (ao *AggregateOptionsBuilder) SetLet(let interface{}) *AggregateOptionsBuilder
- func (ao *AggregateOptionsBuilder) SetMaxAwaitTime(d time.Duration) *AggregateOptionsBuilder
- type ArrayFilters
- type AutoEncryptionOptions
- type AutoEncryptionOptionsBuilder
- func (a *AutoEncryptionOptionsBuilder) List() []func(*AutoEncryptionOptions) error
- func (a *AutoEncryptionOptionsBuilder) SetBypassAutoEncryption(bypass bool) *AutoEncryptionOptionsBuilder
- func (a *AutoEncryptionOptionsBuilder) SetBypassQueryAnalysis(bypass bool) *AutoEncryptionOptionsBuilder
- func (a *AutoEncryptionOptionsBuilder) SetEncryptedFieldsMap(ef map[string]interface{}) *AutoEncryptionOptionsBuilder
- func (a *AutoEncryptionOptionsBuilder) SetExtraOptions(extraOpts map[string]interface{}) *AutoEncryptionOptionsBuilder
- func (a *AutoEncryptionOptionsBuilder) SetKeyVaultClientOptions(opts Lister[ClientOptions]) *AutoEncryptionOptionsBuilder
- func (a *AutoEncryptionOptionsBuilder) SetKeyVaultNamespace(ns string) *AutoEncryptionOptionsBuilder
- func (a *AutoEncryptionOptionsBuilder) SetKmsProviders(providers map[string]map[string]interface{}) *AutoEncryptionOptionsBuilder
- func (a *AutoEncryptionOptionsBuilder) SetSchemaMap(schemaMap map[string]interface{}) *AutoEncryptionOptionsBuilder
- func (a *AutoEncryptionOptionsBuilder) SetTLSConfig(tlsOpts map[string]*tls.Config) *AutoEncryptionOptionsBuilder
- type BSONOptions
- type BucketOptions
- type BucketOptionsBuilder
- func (b *BucketOptionsBuilder) List() []func(*BucketOptions) error
- func (b *BucketOptionsBuilder) SetChunkSizeBytes(i int32) *BucketOptionsBuilder
- func (b *BucketOptionsBuilder) SetName(name string) *BucketOptionsBuilder
- func (b *BucketOptionsBuilder) SetReadConcern(rc *readconcern.ReadConcern) *BucketOptionsBuilder
- func (b *BucketOptionsBuilder) SetReadPreference(rp *readpref.ReadPref) *BucketOptionsBuilder
- func (b *BucketOptionsBuilder) SetWriteConcern(wc *writeconcern.WriteConcern) *BucketOptionsBuilder
- type BulkWriteOptions
- type BulkWriteOptionsBuilder
- func (b *BulkWriteOptionsBuilder) List() []func(*BulkWriteOptions) error
- func (b *BulkWriteOptionsBuilder) SetBypassDocumentValidation(bypass bool) *BulkWriteOptionsBuilder
- func (b *BulkWriteOptionsBuilder) SetComment(comment interface{}) *BulkWriteOptionsBuilder
- func (b *BulkWriteOptionsBuilder) SetLet(let interface{}) *BulkWriteOptionsBuilder
- func (b *BulkWriteOptionsBuilder) SetOrdered(ordered bool) *BulkWriteOptionsBuilder
- type ChangeStreamOptions
- type ChangeStreamOptionsBuilder
- func (cso *ChangeStreamOptionsBuilder) List() []func(*ChangeStreamOptions) error
- func (cso *ChangeStreamOptionsBuilder) SetBatchSize(i int32) *ChangeStreamOptionsBuilder
- func (cso *ChangeStreamOptionsBuilder) SetCollation(c Collation) *ChangeStreamOptionsBuilder
- func (cso *ChangeStreamOptionsBuilder) SetComment(comment interface{}) *ChangeStreamOptionsBuilder
- func (cso *ChangeStreamOptionsBuilder) SetCustom(c bson.M) *ChangeStreamOptionsBuilder
- func (cso *ChangeStreamOptionsBuilder) SetCustomPipeline(cp bson.M) *ChangeStreamOptionsBuilder
- func (cso *ChangeStreamOptionsBuilder) SetFullDocument(fd FullDocument) *ChangeStreamOptionsBuilder
- func (cso *ChangeStreamOptionsBuilder) SetFullDocumentBeforeChange(fdbc FullDocument) *ChangeStreamOptionsBuilder
- func (cso *ChangeStreamOptionsBuilder) SetMaxAwaitTime(d time.Duration) *ChangeStreamOptionsBuilder
- func (cso *ChangeStreamOptionsBuilder) SetResumeAfter(rt interface{}) *ChangeStreamOptionsBuilder
- func (cso *ChangeStreamOptionsBuilder) SetShowExpandedEvents(see bool) *ChangeStreamOptionsBuilder
- func (cso *ChangeStreamOptionsBuilder) SetStartAfter(sa interface{}) *ChangeStreamOptionsBuilder
- func (cso *ChangeStreamOptionsBuilder) SetStartAtOperationTime(t *bson.Timestamp) *ChangeStreamOptionsBuilder
- type ClientEncryptionOptions
- type ClientEncryptionOptionsBuilder
- func (c *ClientEncryptionOptionsBuilder) List() []func(*ClientEncryptionOptions) error
- func (c *ClientEncryptionOptionsBuilder) SetKeyVaultNamespace(ns string) *ClientEncryptionOptionsBuilder
- func (c *ClientEncryptionOptionsBuilder) SetKmsProviders(providers map[string]map[string]interface{}) *ClientEncryptionOptionsBuilder
- func (c *ClientEncryptionOptionsBuilder) SetTLSConfig(tlsOpts map[string]*tls.Config) *ClientEncryptionOptionsBuilder
- type ClientOptions
- type ClientOptionsBuilder
- func (c *ClientOptionsBuilder) ApplyURI(uri string) *ClientOptionsBuilder
- func (c *ClientOptionsBuilder) GetURI() string
- func (c *ClientOptionsBuilder) List() []func(*ClientOptions) error
- func (c *ClientOptionsBuilder) SetAppName(s string) *ClientOptionsBuilder
- func (c *ClientOptionsBuilder) SetAuth(auth Credential) *ClientOptionsBuilder
- func (c *ClientOptionsBuilder) SetAutoEncryptionOptions(aeopts Lister[AutoEncryptionOptions]) *ClientOptionsBuilder
- func (c *ClientOptionsBuilder) SetBSONOptions(bopts *BSONOptions) *ClientOptionsBuilder
- func (c *ClientOptionsBuilder) SetCompressors(comps []string) *ClientOptionsBuilder
- func (c *ClientOptionsBuilder) SetConnectTimeout(d time.Duration) *ClientOptionsBuilder
- func (c *ClientOptionsBuilder) SetDialer(d ContextDialer) *ClientOptionsBuilder
- func (c *ClientOptionsBuilder) SetDirect(b bool) *ClientOptionsBuilder
- func (c *ClientOptionsBuilder) SetDisableOCSPEndpointCheck(disableCheck bool) *ClientOptionsBuilder
- func (c *ClientOptionsBuilder) SetHTTPClient(client *http.Client) *ClientOptionsBuilder
- func (c *ClientOptionsBuilder) SetHeartbeatInterval(d time.Duration) *ClientOptionsBuilder
- func (c *ClientOptionsBuilder) SetHosts(s []string) *ClientOptionsBuilder
- func (c *ClientOptionsBuilder) SetLoadBalanced(lb bool) *ClientOptionsBuilder
- func (c *ClientOptionsBuilder) SetLocalThreshold(d time.Duration) *ClientOptionsBuilder
- func (c *ClientOptionsBuilder) SetLoggerOptions(lopts Lister[LoggerOptions]) *ClientOptionsBuilder
- func (c *ClientOptionsBuilder) SetMaxConnIdleTime(d time.Duration) *ClientOptionsBuilder
- func (c *ClientOptionsBuilder) SetMaxConnecting(u uint64) *ClientOptionsBuilder
- func (c *ClientOptionsBuilder) SetMaxPoolSize(u uint64) *ClientOptionsBuilder
- func (c *ClientOptionsBuilder) SetMinPoolSize(u uint64) *ClientOptionsBuilder
- func (c *ClientOptionsBuilder) SetMonitor(m *event.CommandMonitor) *ClientOptionsBuilder
- func (c *ClientOptionsBuilder) SetPoolMonitor(m *event.PoolMonitor) *ClientOptionsBuilder
- func (c *ClientOptionsBuilder) SetReadConcern(rc *readconcern.ReadConcern) *ClientOptionsBuilder
- func (c *ClientOptionsBuilder) SetReadPreference(rp *readpref.ReadPref) *ClientOptionsBuilder
- func (c *ClientOptionsBuilder) SetRegistry(registry *bson.Registry) *ClientOptionsBuilder
- func (c *ClientOptionsBuilder) SetReplicaSet(s string) *ClientOptionsBuilder
- func (c *ClientOptionsBuilder) SetRetryReads(b bool) *ClientOptionsBuilder
- func (c *ClientOptionsBuilder) SetRetryWrites(b bool) *ClientOptionsBuilder
- func (c *ClientOptionsBuilder) SetSRVMaxHosts(srvMaxHosts int) *ClientOptionsBuilder
- func (c *ClientOptionsBuilder) SetSRVServiceName(srvName string) *ClientOptionsBuilder
- func (c *ClientOptionsBuilder) SetServerAPIOptions(sopts Lister[ServerAPIOptions]) *ClientOptionsBuilder
- func (c *ClientOptionsBuilder) SetServerMonitor(m *event.ServerMonitor) *ClientOptionsBuilder
- func (c *ClientOptionsBuilder) SetServerMonitoringMode(mode string) *ClientOptionsBuilder
- func (c *ClientOptionsBuilder) SetServerSelectionTimeout(d time.Duration) *ClientOptionsBuilder
- func (c *ClientOptionsBuilder) SetTLSConfig(cfg *tls.Config) *ClientOptionsBuilder
- func (c *ClientOptionsBuilder) SetTimeout(d time.Duration) *ClientOptionsBuilder
- func (c *ClientOptionsBuilder) SetWriteConcern(wc *writeconcern.WriteConcern) *ClientOptionsBuilder
- func (c *ClientOptionsBuilder) SetZlibLevel(level int) *ClientOptionsBuilder
- func (c *ClientOptionsBuilder) SetZstdLevel(level int) *ClientOptionsBuilder
- func (c *ClientOptionsBuilder) Validate() error
- type Collation
- type CollectionOptions
- type CollectionOptionsBuilder
- func (c *CollectionOptionsBuilder) List() []func(*CollectionOptions) error
- func (c *CollectionOptionsBuilder) SetBSONOptions(bopts *BSONOptions) *CollectionOptionsBuilder
- func (c *CollectionOptionsBuilder) SetReadConcern(rc *readconcern.ReadConcern) *CollectionOptionsBuilder
- func (c *CollectionOptionsBuilder) SetReadPreference(rp *readpref.ReadPref) *CollectionOptionsBuilder
- func (c *CollectionOptionsBuilder) SetRegistry(r *bson.Registry) *CollectionOptionsBuilder
- func (c *CollectionOptionsBuilder) SetWriteConcern(wc *writeconcern.WriteConcern) *CollectionOptionsBuilder
- type ContextDialer
- type CountOptions
- type CountOptionsBuilder
- func (co *CountOptionsBuilder) List() []func(*CountOptions) error
- func (co *CountOptionsBuilder) SetCollation(c *Collation) *CountOptionsBuilder
- func (co *CountOptionsBuilder) SetComment(comment interface{}) *CountOptionsBuilder
- func (co *CountOptionsBuilder) SetHint(h interface{}) *CountOptionsBuilder
- func (co *CountOptionsBuilder) SetLimit(i int64) *CountOptionsBuilder
- func (co *CountOptionsBuilder) SetSkip(i int64) *CountOptionsBuilder
- type CreateCollectionOptions
- type CreateCollectionOptionsBuilder
- func (c *CreateCollectionOptionsBuilder) List() []func(*CreateCollectionOptions) error
- func (c *CreateCollectionOptionsBuilder) SetCapped(capped bool) *CreateCollectionOptionsBuilder
- func (c *CreateCollectionOptionsBuilder) SetChangeStreamPreAndPostImages(csppi interface{}) *CreateCollectionOptionsBuilder
- func (c *CreateCollectionOptionsBuilder) SetClusteredIndex(clusteredIndex interface{}) *CreateCollectionOptionsBuilder
- func (c *CreateCollectionOptionsBuilder) SetCollation(collation *Collation) *CreateCollectionOptionsBuilder
- func (c *CreateCollectionOptionsBuilder) SetDefaultIndexOptions(iopts *DefaultIndexOptionsBuilder) *CreateCollectionOptionsBuilder
- func (c *CreateCollectionOptionsBuilder) SetEncryptedFields(encryptedFields interface{}) *CreateCollectionOptionsBuilder
- func (c *CreateCollectionOptionsBuilder) SetExpireAfterSeconds(eas int64) *CreateCollectionOptionsBuilder
- func (c *CreateCollectionOptionsBuilder) SetMaxDocuments(max int64) *CreateCollectionOptionsBuilder
- func (c *CreateCollectionOptionsBuilder) SetSizeInBytes(size int64) *CreateCollectionOptionsBuilder
- func (c *CreateCollectionOptionsBuilder) SetStorageEngine(storageEngine interface{}) *CreateCollectionOptionsBuilder
- func (c *CreateCollectionOptionsBuilder) SetTimeSeriesOptions(timeSeriesOpts *TimeSeriesOptionsBuilder) *CreateCollectionOptionsBuilder
- func (c *CreateCollectionOptionsBuilder) SetValidationAction(action string) *CreateCollectionOptionsBuilder
- func (c *CreateCollectionOptionsBuilder) SetValidationLevel(level string) *CreateCollectionOptionsBuilder
- func (c *CreateCollectionOptionsBuilder) SetValidator(validator interface{}) *CreateCollectionOptionsBuilder
- type CreateIndexesOptions
- type CreateIndexesOptionsBuilder
- func (c *CreateIndexesOptionsBuilder) List() []func(*CreateIndexesOptions) error
- func (c *CreateIndexesOptionsBuilder) SetCommitQuorumInt(quorum int32) *CreateIndexesOptionsBuilder
- func (c *CreateIndexesOptionsBuilder) SetCommitQuorumMajority() *CreateIndexesOptionsBuilder
- func (c *CreateIndexesOptionsBuilder) SetCommitQuorumString(quorum string) *CreateIndexesOptionsBuilder
- func (c *CreateIndexesOptionsBuilder) SetCommitQuorumVotingMembers() *CreateIndexesOptionsBuilder
- type CreateSearchIndexesOptions
- type CreateSearchIndexesOptionsBuilder
- type CreateViewOptions
- type CreateViewOptionsBuilder
- type Credential
- type CursorType
- type DataKeyOptions
- type DataKeyOptionsBuilder
- func (dk *DataKeyOptionsBuilder) List() []func(*DataKeyOptions) error
- func (dk *DataKeyOptionsBuilder) SetKeyAltNames(keyAltNames []string) *DataKeyOptionsBuilder
- func (dk *DataKeyOptionsBuilder) SetKeyMaterial(keyMaterial []byte) *DataKeyOptionsBuilder
- func (dk *DataKeyOptionsBuilder) SetMasterKey(masterKey interface{}) *DataKeyOptionsBuilder
- type DatabaseOptions
- type DatabaseOptionsBuilder
- func (d *DatabaseOptionsBuilder) List() []func(*DatabaseOptions) error
- func (d *DatabaseOptionsBuilder) SetBSONOptions(bopts *BSONOptions) *DatabaseOptionsBuilder
- func (d *DatabaseOptionsBuilder) SetReadConcern(rc *readconcern.ReadConcern) *DatabaseOptionsBuilder
- func (d *DatabaseOptionsBuilder) SetReadPreference(rp *readpref.ReadPref) *DatabaseOptionsBuilder
- func (d *DatabaseOptionsBuilder) SetRegistry(r *bson.Registry) *DatabaseOptionsBuilder
- func (d *DatabaseOptionsBuilder) SetWriteConcern(wc *writeconcern.WriteConcern) *DatabaseOptionsBuilder
- type DefaultIndexOptions
- type DefaultIndexOptionsBuilder
- type DeleteOptions
- type DeleteOptionsBuilder
- func (do *DeleteOptionsBuilder) List() []func(*DeleteOptions) error
- func (do *DeleteOptionsBuilder) SetCollation(c *Collation) *DeleteOptionsBuilder
- func (do *DeleteOptionsBuilder) SetComment(comment interface{}) *DeleteOptionsBuilder
- func (do *DeleteOptionsBuilder) SetHint(hint interface{}) *DeleteOptionsBuilder
- func (do *DeleteOptionsBuilder) SetLet(let interface{}) *DeleteOptionsBuilder
- type DistinctOptions
- type DistinctOptionsBuilder
- type DropCollectionOptions
- type DropCollectionOptionsBuilder
- type DropIndexesOptions
- type DropIndexesOptionsBuilder
- type DropSearchIndexOptions
- type DropSearchIndexOptionsBuilder
- type EncryptOptions
- type EncryptOptionsBuilder
- func (e *EncryptOptionsBuilder) List() []func(*EncryptOptions) error
- func (e *EncryptOptionsBuilder) SetAlgorithm(algorithm string) *EncryptOptionsBuilder
- func (e *EncryptOptionsBuilder) SetContentionFactor(contentionFactor int64) *EncryptOptionsBuilder
- func (e *EncryptOptionsBuilder) SetKeyAltName(keyAltName string) *EncryptOptionsBuilder
- func (e *EncryptOptionsBuilder) SetKeyID(keyID bson.Binary) *EncryptOptionsBuilder
- func (e *EncryptOptionsBuilder) SetQueryType(queryType string) *EncryptOptionsBuilder
- func (e *EncryptOptionsBuilder) SetRangeOptions(ro *RangeOptionsBuilder) *EncryptOptionsBuilder
- type EstimatedDocumentCountOptions
- type EstimatedDocumentCountOptionsBuilder
- type FindOneAndDeleteOptions
- type FindOneAndDeleteOptionsBuilder
- func (f *FindOneAndDeleteOptionsBuilder) List() []func(*FindOneAndDeleteOptions) error
- func (f *FindOneAndDeleteOptionsBuilder) SetCollation(collation *Collation) *FindOneAndDeleteOptionsBuilder
- func (f *FindOneAndDeleteOptionsBuilder) SetComment(comment interface{}) *FindOneAndDeleteOptionsBuilder
- func (f *FindOneAndDeleteOptionsBuilder) SetHint(hint interface{}) *FindOneAndDeleteOptionsBuilder
- func (f *FindOneAndDeleteOptionsBuilder) SetLet(let interface{}) *FindOneAndDeleteOptionsBuilder
- func (f *FindOneAndDeleteOptionsBuilder) SetProjection(projection interface{}) *FindOneAndDeleteOptionsBuilder
- func (f *FindOneAndDeleteOptionsBuilder) SetSort(sort interface{}) *FindOneAndDeleteOptionsBuilder
- type FindOneAndReplaceOptions
- type FindOneAndReplaceOptionsBuilder
- func (f *FindOneAndReplaceOptionsBuilder) List() []func(*FindOneAndReplaceOptions) error
- func (f *FindOneAndReplaceOptionsBuilder) SetBypassDocumentValidation(b bool) *FindOneAndReplaceOptionsBuilder
- func (f *FindOneAndReplaceOptionsBuilder) SetCollation(collation *Collation) *FindOneAndReplaceOptionsBuilder
- func (f *FindOneAndReplaceOptionsBuilder) SetComment(comment interface{}) *FindOneAndReplaceOptionsBuilder
- func (f *FindOneAndReplaceOptionsBuilder) SetHint(hint interface{}) *FindOneAndReplaceOptionsBuilder
- func (f *FindOneAndReplaceOptionsBuilder) SetLet(let interface{}) *FindOneAndReplaceOptionsBuilder
- func (f *FindOneAndReplaceOptionsBuilder) SetProjection(projection interface{}) *FindOneAndReplaceOptionsBuilder
- func (f *FindOneAndReplaceOptionsBuilder) SetReturnDocument(rd ReturnDocument) *FindOneAndReplaceOptionsBuilder
- func (f *FindOneAndReplaceOptionsBuilder) SetSort(sort interface{}) *FindOneAndReplaceOptionsBuilder
- func (f *FindOneAndReplaceOptionsBuilder) SetUpsert(b bool) *FindOneAndReplaceOptionsBuilder
- type FindOneAndUpdateOptions
- type FindOneAndUpdateOptionsBuilder
- func (f *FindOneAndUpdateOptionsBuilder) List() []func(*FindOneAndUpdateOptions) error
- func (f *FindOneAndUpdateOptionsBuilder) SetArrayFilters(filters ArrayFilters) *FindOneAndUpdateOptionsBuilder
- func (f *FindOneAndUpdateOptionsBuilder) SetBypassDocumentValidation(b bool) *FindOneAndUpdateOptionsBuilder
- func (f *FindOneAndUpdateOptionsBuilder) SetCollation(collation *Collation) *FindOneAndUpdateOptionsBuilder
- func (f *FindOneAndUpdateOptionsBuilder) SetComment(comment interface{}) *FindOneAndUpdateOptionsBuilder
- func (f *FindOneAndUpdateOptionsBuilder) SetHint(hint interface{}) *FindOneAndUpdateOptionsBuilder
- func (f *FindOneAndUpdateOptionsBuilder) SetLet(let interface{}) *FindOneAndUpdateOptionsBuilder
- func (f *FindOneAndUpdateOptionsBuilder) SetProjection(projection interface{}) *FindOneAndUpdateOptionsBuilder
- func (f *FindOneAndUpdateOptionsBuilder) SetReturnDocument(rd ReturnDocument) *FindOneAndUpdateOptionsBuilder
- func (f *FindOneAndUpdateOptionsBuilder) SetSort(sort interface{}) *FindOneAndUpdateOptionsBuilder
- func (f *FindOneAndUpdateOptionsBuilder) SetUpsert(b bool) *FindOneAndUpdateOptionsBuilder
- type FindOneOptions
- type FindOneOptionsBuilder
- func (f *FindOneOptionsBuilder) List() []func(*FindOneOptions) error
- func (f *FindOneOptionsBuilder) SetAllowPartialResults(b bool) *FindOneOptionsBuilder
- func (f *FindOneOptionsBuilder) SetCollation(collation *Collation) *FindOneOptionsBuilder
- func (f *FindOneOptionsBuilder) SetComment(comment interface{}) *FindOneOptionsBuilder
- func (f *FindOneOptionsBuilder) SetHint(hint interface{}) *FindOneOptionsBuilder
- func (f *FindOneOptionsBuilder) SetMax(max interface{}) *FindOneOptionsBuilder
- func (f *FindOneOptionsBuilder) SetMin(min interface{}) *FindOneOptionsBuilder
- func (f *FindOneOptionsBuilder) SetProjection(projection interface{}) *FindOneOptionsBuilder
- func (f *FindOneOptionsBuilder) SetReturnKey(b bool) *FindOneOptionsBuilder
- func (f *FindOneOptionsBuilder) SetShowRecordID(b bool) *FindOneOptionsBuilder
- func (f *FindOneOptionsBuilder) SetSkip(i int64) *FindOneOptionsBuilder
- func (f *FindOneOptionsBuilder) SetSort(sort interface{}) *FindOneOptionsBuilder
- type FindOptions
- type FindOptionsBuilder
- func (f *FindOptionsBuilder) List() []func(*FindOptions) error
- func (f *FindOptionsBuilder) SetAllowDiskUse(b bool) *FindOptionsBuilder
- func (f *FindOptionsBuilder) SetAllowPartialResults(b bool) *FindOptionsBuilder
- func (f *FindOptionsBuilder) SetBatchSize(i int32) *FindOptionsBuilder
- func (f *FindOptionsBuilder) SetCollation(collation *Collation) *FindOptionsBuilder
- func (f *FindOptionsBuilder) SetComment(comment interface{}) *FindOptionsBuilder
- func (f *FindOptionsBuilder) SetCursorType(ct CursorType) *FindOptionsBuilder
- func (f *FindOptionsBuilder) SetHint(hint interface{}) *FindOptionsBuilder
- func (f *FindOptionsBuilder) SetLet(let interface{}) *FindOptionsBuilder
- func (f *FindOptionsBuilder) SetLimit(i int64) *FindOptionsBuilder
- func (f *FindOptionsBuilder) SetMax(max interface{}) *FindOptionsBuilder
- func (f *FindOptionsBuilder) SetMaxAwaitTime(d time.Duration) *FindOptionsBuilder
- func (f *FindOptionsBuilder) SetMin(min interface{}) *FindOptionsBuilder
- func (f *FindOptionsBuilder) SetNoCursorTimeout(b bool) *FindOptionsBuilder
- func (f *FindOptionsBuilder) SetProjection(projection interface{}) *FindOptionsBuilder
- func (f *FindOptionsBuilder) SetReturnKey(b bool) *FindOptionsBuilder
- func (f *FindOptionsBuilder) SetShowRecordID(b bool) *FindOptionsBuilder
- func (f *FindOptionsBuilder) SetSkip(i int64) *FindOptionsBuilder
- func (f *FindOptionsBuilder) SetSort(sort interface{}) *FindOptionsBuilder
- type FullDocument
- type GridFSFindOptions
- type GridFSFindOptionsBuilder
- func (f *GridFSFindOptionsBuilder) List() []func(*GridFSFindOptions) error
- func (f *GridFSFindOptionsBuilder) SetAllowDiskUse(b bool) *GridFSFindOptionsBuilder
- func (f *GridFSFindOptionsBuilder) SetBatchSize(i int32) *GridFSFindOptionsBuilder
- func (f *GridFSFindOptionsBuilder) SetLimit(i int32) *GridFSFindOptionsBuilder
- func (f *GridFSFindOptionsBuilder) SetNoCursorTimeout(b bool) *GridFSFindOptionsBuilder
- func (f *GridFSFindOptionsBuilder) SetSkip(i int32) *GridFSFindOptionsBuilder
- func (f *GridFSFindOptionsBuilder) SetSort(sort interface{}) *GridFSFindOptionsBuilder
- type GridFSNameOptions
- type GridFSNameOptionsBuilder
- type GridFSUploadOptions
- type GridFSUploadOptionsBuilder
- func (u *GridFSUploadOptionsBuilder) List() []func(*GridFSUploadOptions) error
- func (u *GridFSUploadOptionsBuilder) SetChunkSizeBytes(i int32) *GridFSUploadOptionsBuilder
- func (u *GridFSUploadOptionsBuilder) SetMetadata(doc interface{}) *GridFSUploadOptionsBuilder
- func (u *GridFSUploadOptionsBuilder) SetRegistry(registry *bson.Registry) *GridFSUploadOptionsBuilder
- type IndexOptions
- type IndexOptionsBuilder
- func (i *IndexOptionsBuilder) List() []func(*IndexOptions) error
- func (i *IndexOptionsBuilder) SetBits(bits int32) *IndexOptionsBuilder
- func (i *IndexOptionsBuilder) SetBucketSize(bucketSize int32) *IndexOptionsBuilder
- func (i *IndexOptionsBuilder) SetCollation(collation *Collation) *IndexOptionsBuilder
- func (i *IndexOptionsBuilder) SetDefaultLanguage(language string) *IndexOptionsBuilder
- func (i *IndexOptionsBuilder) SetExpireAfterSeconds(seconds int32) *IndexOptionsBuilder
- func (i *IndexOptionsBuilder) SetHidden(hidden bool) *IndexOptionsBuilder
- func (i *IndexOptionsBuilder) SetLanguageOverride(override string) *IndexOptionsBuilder
- func (i *IndexOptionsBuilder) SetMax(max float64) *IndexOptionsBuilder
- func (i *IndexOptionsBuilder) SetMin(min float64) *IndexOptionsBuilder
- func (i *IndexOptionsBuilder) SetName(name string) *IndexOptionsBuilder
- func (i *IndexOptionsBuilder) SetPartialFilterExpression(expression interface{}) *IndexOptionsBuilder
- func (i *IndexOptionsBuilder) SetSparse(sparse bool) *IndexOptionsBuilder
- func (i *IndexOptionsBuilder) SetSphereVersion(version int32) *IndexOptionsBuilder
- func (i *IndexOptionsBuilder) SetStorageEngine(engine interface{}) *IndexOptionsBuilder
- func (i *IndexOptionsBuilder) SetTextVersion(version int32) *IndexOptionsBuilder
- func (i *IndexOptionsBuilder) SetUnique(unique bool) *IndexOptionsBuilder
- func (i *IndexOptionsBuilder) SetVersion(version int32) *IndexOptionsBuilder
- func (i *IndexOptionsBuilder) SetWeights(weights interface{}) *IndexOptionsBuilder
- func (i *IndexOptionsBuilder) SetWildcardProjection(wildcardProjection interface{}) *IndexOptionsBuilder
- type InsertManyOptions
- type InsertManyOptionsBuilder
- func (imo *InsertManyOptionsBuilder) List() []func(*InsertManyOptions) error
- func (imo *InsertManyOptionsBuilder) SetBypassDocumentValidation(b bool) *InsertManyOptionsBuilder
- func (imo *InsertManyOptionsBuilder) SetComment(comment interface{}) *InsertManyOptionsBuilder
- func (imo *InsertManyOptionsBuilder) SetOrdered(b bool) *InsertManyOptionsBuilder
- type InsertOneOptions
- type InsertOneOptionsBuilder
- type ListCollectionsOptions
- type ListCollectionsOptionsBuilder
- func (lc *ListCollectionsOptionsBuilder) List() []func(*ListCollectionsOptions) error
- func (lc *ListCollectionsOptionsBuilder) SetAuthorizedCollections(b bool) *ListCollectionsOptionsBuilder
- func (lc *ListCollectionsOptionsBuilder) SetBatchSize(size int32) *ListCollectionsOptionsBuilder
- func (lc *ListCollectionsOptionsBuilder) SetNameOnly(b bool) *ListCollectionsOptionsBuilder
- type ListDatabasesOptions
- type ListDatabasesOptionsBuilder
- type ListIndexesOptions
- type ListIndexesOptionsBuilder
- type ListSearchIndexesOptions
- type ListSearchIndexesOptionsBuilder
- type Lister
- type LogComponent
- type LogLevel
- type LogSink
- type LoggerOptions
- type LoggerOptionsBuilder
- func (opts *LoggerOptionsBuilder) List() []func(*LoggerOptions) error
- func (opts *LoggerOptionsBuilder) SetComponentLevel(component LogComponent, level LogLevel) *LoggerOptionsBuilder
- func (opts *LoggerOptionsBuilder) SetMaxDocumentLength(maxDocumentLength uint) *LoggerOptionsBuilder
- func (opts *LoggerOptionsBuilder) SetSink(sink LogSink) *LoggerOptionsBuilder
- type RangeOptions
- type RangeOptionsBuilder
- func (ro *RangeOptionsBuilder) List() []func(*RangeOptions) error
- func (ro *RangeOptionsBuilder) SetMax(max bson.RawValue) *RangeOptionsBuilder
- func (ro *RangeOptionsBuilder) SetMin(min bson.RawValue) *RangeOptionsBuilder
- func (ro *RangeOptionsBuilder) SetPrecision(precision int32) *RangeOptionsBuilder
- func (ro *RangeOptionsBuilder) SetSparsity(sparsity int64) *RangeOptionsBuilder
- type ReplaceOptions
- type ReplaceOptionsBuilder
- func (ro *ReplaceOptionsBuilder) List() []func(*ReplaceOptions) error
- func (ro *ReplaceOptionsBuilder) SetBypassDocumentValidation(b bool) *ReplaceOptionsBuilder
- func (ro *ReplaceOptionsBuilder) SetCollation(c *Collation) *ReplaceOptionsBuilder
- func (ro *ReplaceOptionsBuilder) SetComment(comment interface{}) *ReplaceOptionsBuilder
- func (ro *ReplaceOptionsBuilder) SetHint(h interface{}) *ReplaceOptionsBuilder
- func (ro *ReplaceOptionsBuilder) SetLet(l interface{}) *ReplaceOptionsBuilder
- func (ro *ReplaceOptionsBuilder) SetUpsert(b bool) *ReplaceOptionsBuilder
- type ReturnDocument
- type RewrapManyDataKeyOptions
- type RewrapManyDataKeyOptionsBuilder
- func (rmdko *RewrapManyDataKeyOptionsBuilder) List() []func(*RewrapManyDataKeyOptions) error
- func (rmdko *RewrapManyDataKeyOptionsBuilder) SetMasterKey(masterKey interface{}) *RewrapManyDataKeyOptionsBuilder
- func (rmdko *RewrapManyDataKeyOptionsBuilder) SetProvider(provider string) *RewrapManyDataKeyOptionsBuilder
- type RunCmdOptions
- type RunCmdOptionsBuilder
- type SearchIndexesOptions
- type SearchIndexesOptionsBuilder
- type ServerAPIOptions
- type ServerAPIOptionsBuilder
- type ServerAPIVersion
- type SessionOptions
- type SessionOptionsBuilder
- func (s *SessionOptionsBuilder) List() []func(*SessionOptions) error
- func (s *SessionOptionsBuilder) SetCausalConsistency(b bool) *SessionOptionsBuilder
- func (s *SessionOptionsBuilder) SetDefaultTransactionOptions(dt *TransactionOptionsBuilder) *SessionOptionsBuilder
- func (s *SessionOptionsBuilder) SetSnapshot(b bool) *SessionOptionsBuilder
- type TimeSeriesOptions
- type TimeSeriesOptionsBuilder
- func (tso *TimeSeriesOptionsBuilder) List() []func(*TimeSeriesOptions) error
- func (tso *TimeSeriesOptionsBuilder) SetBucketMaxSpan(dur time.Duration) *TimeSeriesOptionsBuilder
- func (tso *TimeSeriesOptionsBuilder) SetBucketRounding(dur time.Duration) *TimeSeriesOptionsBuilder
- func (tso *TimeSeriesOptionsBuilder) SetGranularity(granularity string) *TimeSeriesOptionsBuilder
- func (tso *TimeSeriesOptionsBuilder) SetMetaField(metaField string) *TimeSeriesOptionsBuilder
- func (tso *TimeSeriesOptionsBuilder) SetTimeField(timeField string) *TimeSeriesOptionsBuilder
- type TransactionOptions
- type TransactionOptionsBuilder
- func (t *TransactionOptionsBuilder) List() []func(*TransactionOptions) error
- func (t *TransactionOptionsBuilder) SetReadConcern(rc *readconcern.ReadConcern) *TransactionOptionsBuilder
- func (t *TransactionOptionsBuilder) SetReadPreference(rp *readpref.ReadPref) *TransactionOptionsBuilder
- func (t *TransactionOptionsBuilder) SetWriteConcern(wc *writeconcern.WriteConcern) *TransactionOptionsBuilder
- type UpdateOptions
- type UpdateOptionsBuilder
- func (uo *UpdateOptionsBuilder) List() []func(*UpdateOptions) error
- func (uo *UpdateOptionsBuilder) SetArrayFilters(af ArrayFilters) *UpdateOptionsBuilder
- func (uo *UpdateOptionsBuilder) SetBypassDocumentValidation(b bool) *UpdateOptionsBuilder
- func (uo *UpdateOptionsBuilder) SetCollation(c *Collation) *UpdateOptionsBuilder
- func (uo *UpdateOptionsBuilder) SetComment(comment interface{}) *UpdateOptionsBuilder
- func (uo *UpdateOptionsBuilder) SetHint(h interface{}) *UpdateOptionsBuilder
- func (uo *UpdateOptionsBuilder) SetLet(l interface{}) *UpdateOptionsBuilder
- func (uo *UpdateOptionsBuilder) SetUpsert(b bool) *UpdateOptionsBuilder
- type UpdateSearchIndexOptions
- type UpdateSearchIndexOptionsBuilder
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 (
QueryTypeEquality string = "equality"
)
These constants specify valid values for QueryType QueryType is used for Queryable Encryption.
Variables ¶
var DefaultCausalConsistency = true
DefaultCausalConsistency is the default value for the CausalConsistency option.
var DefaultChunkSize int32 = 255 * 1024
DefaultChunkSize 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 = true
DefaultOrdered is the default value for the Ordered option in BulkWriteOptions.
var DefaultRevision int32 = -1
DefaultRevision is the default revision number for a download by name operation.
Functions ¶
func BuildTLSConfig ¶
BuildTLSConfig specifies tls.Config options for each KMS provider to use to configure TLS on all connections created to the KMS provider. The input map should contain a mapping from each KMS provider to a document containing the necessary options, 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 to the client certificate and private key, which must be concatenated into one file.
2. "tlsCertificateKeyFilePassword" (or "sslClientCertificateKeyPassword"): Specify the password to decrypt the client private key file (e.g. "tlsCertificateKeyFilePassword=password").
3. "tlsCaFile" (or "sslCertificateAuthorityFile"): Specify the path to a single or bundle of certificate authorities to 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 ¶
type AggregateOptions ¶
type AggregateOptions struct { // If true, the operation can write to temporary files in the _tmp subdirectory of the database directory path on // the server. The default value is false. AllowDiskUse *bool // The maximum number of documents to be included in each batch returned by the server. BatchSize *int32 // If true, writes executed as part of the operation will opt out of document-level validation on the server. This // option is valid for MongoDB versions >= 3.2 and is ignored for previous server versions. The default value is // false. See https://www.mongodb.com/docs/manual/core/schema-validation/ for more information about document // validation. BypassDocumentValidation *bool // Specifies a collation to use for string comparisons during the operation. This option is only valid for MongoDB // versions >= 3.4. For previous server versions, the driver will return an error if this option is used. The // default value is nil, which means the default collation of the collection will be used. Collation *Collation // The maximum amount of time that the server should wait for new documents to satisfy a tailable cursor query. // This option is only valid for MongoDB versions >= 3.2 and is ignored for previous server versions. MaxAwaitTime *time.Duration // A string or document that will be included in server logs, profiling logs, // and currentOp queries to help trace the operation. The default is nil, // which means that no comment will be included in the logs. Comment interface{} // The index to use for the aggregation. This should either be the index name as a string or the index specification // as a document. The hint does not apply to $lookup and $graphLookup aggregation stages. The driver will return an // error if the hint parameter is a multi-key map. The default value is nil, which means that no hint will be sent. Hint interface{} // Specifies parameters for the aggregate expression. This option is only valid for MongoDB versions >= 5.0. Older // servers will report an error for using this option. This must be a document mapping parameter names to values. // Values must be constant or closed expressions that do not reference document fields. Parameters can then be // accessed as variables in an aggregate expression context (e.g. "$$var"). Let interface{} // Custom options to be added to aggregate expression. Key-value pairs of the BSON map should correlate with desired // option names and values. Values must be Marshalable. Custom options may conflict with non-custom options, and custom // options bypass client-side validation. Prefer using non-custom options where possible. Custom bson.M }
AggregateOptions represents arguments that can be used to configure an Aggregate operation.
type AggregateOptionsBuilder ¶
type AggregateOptionsBuilder struct {
Opts []func(*AggregateOptions) error
}
AggregateOptionsBuilder contains options to configure aggregate operations. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func Aggregate ¶
func Aggregate() *AggregateOptionsBuilder
Aggregate creates a new AggregateOptions instance.
func (*AggregateOptionsBuilder) List ¶
func (ao *AggregateOptionsBuilder) List() []func(*AggregateOptions) error
List returns a list of AggergateOptions setter functions.
func (*AggregateOptionsBuilder) SetAllowDiskUse ¶
func (ao *AggregateOptionsBuilder) SetAllowDiskUse(b bool) *AggregateOptionsBuilder
SetAllowDiskUse sets the value for the AllowDiskUse field.
func (*AggregateOptionsBuilder) SetBatchSize ¶
func (ao *AggregateOptionsBuilder) SetBatchSize(i int32) *AggregateOptionsBuilder
SetBatchSize sets the value for the BatchSize field.
func (*AggregateOptionsBuilder) SetBypassDocumentValidation ¶
func (ao *AggregateOptionsBuilder) SetBypassDocumentValidation(b bool) *AggregateOptionsBuilder
SetBypassDocumentValidation sets the value for the BypassDocumentValidation field.
func (*AggregateOptionsBuilder) SetCollation ¶
func (ao *AggregateOptionsBuilder) SetCollation(c *Collation) *AggregateOptionsBuilder
SetCollation sets the value for the Collation field.
func (*AggregateOptionsBuilder) SetComment ¶
func (ao *AggregateOptionsBuilder) SetComment(comment interface{}) *AggregateOptionsBuilder
SetComment sets the value for the Comment field.
func (*AggregateOptionsBuilder) SetCustom ¶
func (ao *AggregateOptionsBuilder) SetCustom(c bson.M) *AggregateOptionsBuilder
SetCustom sets the value for the Custom field. 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.
func (*AggregateOptionsBuilder) SetHint ¶
func (ao *AggregateOptionsBuilder) SetHint(h interface{}) *AggregateOptionsBuilder
SetHint sets the value for the Hint field.
func (*AggregateOptionsBuilder) SetLet ¶
func (ao *AggregateOptionsBuilder) SetLet(let interface{}) *AggregateOptionsBuilder
SetLet sets the value for the Let field.
func (*AggregateOptionsBuilder) SetMaxAwaitTime ¶
func (ao *AggregateOptionsBuilder) SetMaxAwaitTime(d time.Duration) *AggregateOptionsBuilder
SetMaxAwaitTime sets the value for the MaxAwaitTime field.
type ArrayFilters ¶
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 *bson.Registry Filters []interface{} // The filters to apply }
ArrayFilters is used to hold filters for the array filters CRUD option. If a registry is nil, bson.DefaultRegistry will be used when converting the filter interfaces to BSON.
func (*ArrayFilters) ToArray
deprecated
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) ToArrayDocument
deprecated
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.
type AutoEncryptionOptions ¶
type AutoEncryptionOptions struct { KeyVaultClientOptions Lister[ClientOptions] KeyVaultNamespace string KmsProviders map[string]map[string]interface{} SchemaMap map[string]interface{} BypassAutoEncryption *bool ExtraOptions map[string]interface{} TLSConfig map[string]*tls.Config HTTPClient *http.Client EncryptedFieldsMap map[string]interface{} BypassQueryAnalysis *bool }
AutoEncryptionOptions represents arguments used to configure auto encryption/decryption behavior for a mongo.Client instance.
Automatic encryption is an enterprise only feature that only applies to operations on a collection. Automatic encryption is not supported for operations on a database or view, and operations that are not bypassed will result in 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 use ClientEncryption.encrypt() to manually encrypt values.
Enabling Client Side Encryption reduces the maximum document and message size (using a maxBsonObjectSize of 2MiB and maxMessageSizeBytes of 6MB) and may have a negative performance impact.
type AutoEncryptionOptionsBuilder ¶
type AutoEncryptionOptionsBuilder struct {
Opts []func(*AutoEncryptionOptions) error
}
AutoEncryptionOptionsBuilder contains options to configure automatic encryption for operations. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func AutoEncryption ¶
func AutoEncryption() *AutoEncryptionOptionsBuilder
AutoEncryption creates a new AutoEncryptionOptions configured with default values.
func (*AutoEncryptionOptionsBuilder) List ¶
func (a *AutoEncryptionOptionsBuilder) List() []func(*AutoEncryptionOptions) error
List returns a list of AutoEncryptionOptions setter functions.
func (*AutoEncryptionOptionsBuilder) SetBypassAutoEncryption ¶
func (a *AutoEncryptionOptionsBuilder) SetBypassAutoEncryption(bypass bool) *AutoEncryptionOptionsBuilder
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 is unset). The internal mongo.Client is configured with the same options as the target mongo.Client except minPoolSize is set to 0 and AutoEncryptionOptions is omitted.
func (*AutoEncryptionOptionsBuilder) SetBypassQueryAnalysis ¶
func (a *AutoEncryptionOptionsBuilder) SetBypassQueryAnalysis(bypass bool) *AutoEncryptionOptionsBuilder
SetBypassQueryAnalysis specifies whether or not query analysis should be used for automatic encryption. Use this option when using explicit encryption with Queryable Encryption.
func (*AutoEncryptionOptionsBuilder) SetEncryptedFieldsMap ¶
func (a *AutoEncryptionOptionsBuilder) SetEncryptedFieldsMap(ef map[string]interface{}) *AutoEncryptionOptionsBuilder
SetEncryptedFieldsMap specifies a map from namespace to local EncryptedFieldsMap document. EncryptedFieldsMap is used for Queryable Encryption.
func (*AutoEncryptionOptionsBuilder) SetExtraOptions ¶
func (a *AutoEncryptionOptionsBuilder) SetExtraOptions(extraOpts map[string]interface{}) *AutoEncryptionOptionsBuilder
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 the mongocryptd process. The default is "mongodb://localhost:27020", which works with the default mongocryptd process spawned by the Client. Must be a string.
"mongocryptdBypassSpawn" - If set to true, the Client will not attempt to spawn a mongocryptd process. 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 the crypt_shared library is not loaded. If unset or set to false, Client creation will not return an error 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 the crypt_shared dynamic library file (for example, a .so, .dll, or .dylib file), not the directory that contains it. If the override path is a relative path, it will be resolved relative to the working directory of the process. If the override path is a relative path and the first path component is the literal string "$ORIGIN", the "$ORIGIN" component will be replaced by the absolute path to the directory containing the linked libmongocrypt library. Setting an override path disables the default system library search path. If an override path is specified but the crypt_shared library cannot be loaded, Client creation will return an error. Must be a string.
func (*AutoEncryptionOptionsBuilder) SetKeyVaultClientOptions ¶
func (a *AutoEncryptionOptionsBuilder) SetKeyVaultClientOptions(opts Lister[ClientOptions]) *AutoEncryptionOptionsBuilder
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 (if BypassAutomaticEncryption is false). The internal mongo.Client is configured with the same options as the target mongo.Client except minPoolSize is set to 0 and AutoEncryptionOptions is omitted.
func (*AutoEncryptionOptionsBuilder) SetKeyVaultNamespace ¶
func (a *AutoEncryptionOptionsBuilder) SetKeyVaultNamespace(ns string) *AutoEncryptionOptionsBuilder
SetKeyVaultNamespace specifies the namespace of the key vault collection. This is required.
func (*AutoEncryptionOptionsBuilder) SetKmsProviders ¶
func (a *AutoEncryptionOptionsBuilder) SetKmsProviders(providers map[string]map[string]interface{}) *AutoEncryptionOptionsBuilder
SetKmsProviders specifies options for KMS providers. This is required.
func (*AutoEncryptionOptionsBuilder) SetSchemaMap ¶
func (a *AutoEncryptionOptionsBuilder) SetSchemaMap(schemaMap map[string]interface{}) *AutoEncryptionOptionsBuilder
SetSchemaMap specifies a map from namespace to local schema document. Schemas supplied in the schemaMap only apply to configuring automatic encryption for client side encryption. Other validation rules in the JSON schema will not be 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 protects against a malicious server advertising a false JSON Schema, which could trick the client into sending unencrypted data that should be encrypted.
func (*AutoEncryptionOptionsBuilder) SetTLSConfig ¶
func (a *AutoEncryptionOptionsBuilder) SetTLSConfig(tlsOpts map[string]*tls.Config) *AutoEncryptionOptionsBuilder
SetTLSConfig specifies tls.Config instances for each KMS provider to use to configure TLS on all connections created to 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.
type BSONOptions ¶
type BSONOptions struct { // UseJSONStructTags causes the driver to fall back to using the "json" // struct tag if a "bson" struct tag is not specified. UseJSONStructTags bool // 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. ErrorOnInlineDuplicates bool // 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. IntMinSize bool // 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. NilMapAsEmpty bool // 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. NilSliceAsEmpty bool // NilByteSliceAsEmpty causes the driver to marshal nil Go byte slices as // empty BSON binary values instead of BSON null. NilByteSliceAsEmpty bool // 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. OmitZeroStruct bool // 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. StringifyMapKeysWithFmt bool // 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. AllowTruncatingDoubles bool // 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. BinaryAsSlice bool // 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{}". DefaultDocumentM bool // UseLocalTimeZone causes the driver to unmarshal time.Time values in the // local timezone instead of the UTC timezone. UseLocalTimeZone bool // ZeroMaps causes the driver to delete any existing values from Go maps in // the destination value before unmarshaling BSON documents into them. ZeroMaps bool // ZeroStructs causes the driver to delete any existing values from Go // structs in the destination value before unmarshaling BSON documents into // them. ZeroStructs bool }
BSONOptions are optional BSON marshaling and unmarshaling behaviors.
type BucketOptions ¶
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 arguments that can be used to configure GridFS bucket.
type BucketOptionsBuilder ¶
type BucketOptionsBuilder struct {
Opts []func(*BucketOptions) error
}
BucketOptionsBuilder contains options to configure a gridfs bucket. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func GridFSBucket ¶
func GridFSBucket() *BucketOptionsBuilder
GridFSBucket creates a new BucketOptions instance.
func (*BucketOptionsBuilder) List ¶
func (b *BucketOptionsBuilder) List() []func(*BucketOptions) error
List returns a list of CountOptions setter functions.
func (*BucketOptionsBuilder) SetChunkSizeBytes ¶
func (b *BucketOptionsBuilder) SetChunkSizeBytes(i int32) *BucketOptionsBuilder
SetChunkSizeBytes sets the value for the ChunkSize field.
func (*BucketOptionsBuilder) SetName ¶
func (b *BucketOptionsBuilder) SetName(name string) *BucketOptionsBuilder
SetName sets the value for the Name field.
func (*BucketOptionsBuilder) SetReadConcern ¶
func (b *BucketOptionsBuilder) SetReadConcern(rc *readconcern.ReadConcern) *BucketOptionsBuilder
SetReadConcern sets the value for the ReadConcern field.
func (*BucketOptionsBuilder) SetReadPreference ¶
func (b *BucketOptionsBuilder) SetReadPreference(rp *readpref.ReadPref) *BucketOptionsBuilder
SetReadPreference sets the value for the ReadPreference field.
func (*BucketOptionsBuilder) SetWriteConcern ¶
func (b *BucketOptionsBuilder) SetWriteConcern(wc *writeconcern.WriteConcern) *BucketOptionsBuilder
SetWriteConcern sets the value for the WriteConcern field.
type BulkWriteOptions ¶
type BulkWriteOptions struct { // If true, writes executed as part of the operation will opt out of document-level validation on the server. This // option is valid for MongoDB versions >= 3.2 and is ignored for previous server versions. The default value is // false. See https://www.mongodb.com/docs/manual/core/schema-validation/ for more information about document // validation. BypassDocumentValidation *bool // A string or document that will be included in server logs, profiling logs, and currentOp queries to help trace // the operation. The default value is nil, which means that no comment will be included in the logs. Comment interface{} // If true, no writes will be executed after one fails. The default value is true. Ordered *bool // Specifies parameters for all update and delete commands in the BulkWrite. This option is only valid for MongoDB // versions >= 5.0. Older servers will report an error for using this option. This must be a document mapping // parameter names to values. Values must be constant or closed expressions that do not reference document fields. // Parameters can then be accessed as variables in an aggregate expression context (e.g. "$$var"). Let interface{} }
BulkWriteOptions represents arguments that can be used to configure a BulkWrite operation.
type BulkWriteOptionsBuilder ¶
type BulkWriteOptionsBuilder struct {
Opts []func(*BulkWriteOptions) error
}
BulkWriteOptionsBuilder contains options to configure bulk write operations. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func BulkWrite ¶
func BulkWrite() *BulkWriteOptionsBuilder
BulkWrite creates a new *BulkWriteOptions instance.
func (*BulkWriteOptionsBuilder) List ¶
func (b *BulkWriteOptionsBuilder) List() []func(*BulkWriteOptions) error
List returns a list of BulkWriteOptions setter functions.
func (*BulkWriteOptionsBuilder) SetBypassDocumentValidation ¶
func (b *BulkWriteOptionsBuilder) SetBypassDocumentValidation(bypass bool) *BulkWriteOptionsBuilder
SetBypassDocumentValidation sets the value for the BypassDocumentValidation field.
func (*BulkWriteOptionsBuilder) SetComment ¶
func (b *BulkWriteOptionsBuilder) SetComment(comment interface{}) *BulkWriteOptionsBuilder
SetComment sets the value for the Comment field.
func (*BulkWriteOptionsBuilder) SetLet ¶
func (b *BulkWriteOptionsBuilder) SetLet(let interface{}) *BulkWriteOptionsBuilder
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 not reference document fields. Parameters can then be accessed as variables in an aggregate expression context (e.g. "$$var").
func (*BulkWriteOptionsBuilder) SetOrdered ¶
func (b *BulkWriteOptionsBuilder) SetOrdered(ordered bool) *BulkWriteOptionsBuilder
SetOrdered sets the value for the Ordered field.
type ChangeStreamOptions ¶
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 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{} // 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 *bson.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. Custom bson.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. CustomPipeline bson.M }
ChangeStreamOptions represents arguments that can be used to configure a Watch operation.
type ChangeStreamOptionsBuilder ¶
type ChangeStreamOptionsBuilder struct {
Opts []func(*ChangeStreamOptions) error
}
ChangeStreamOptionsBuilder contains options to configure change stream operations. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func ChangeStream ¶
func ChangeStream() *ChangeStreamOptionsBuilder
ChangeStream creates a new ChangeStreamOptions instance.
func (*ChangeStreamOptionsBuilder) List ¶
func (cso *ChangeStreamOptionsBuilder) List() []func(*ChangeStreamOptions) error
List returns a list of ChangeStreamOptions setter functions.
func (*ChangeStreamOptionsBuilder) SetBatchSize ¶
func (cso *ChangeStreamOptionsBuilder) SetBatchSize(i int32) *ChangeStreamOptionsBuilder
SetBatchSize sets the value for the BatchSize field.
func (*ChangeStreamOptionsBuilder) SetCollation ¶
func (cso *ChangeStreamOptionsBuilder) SetCollation(c Collation) *ChangeStreamOptionsBuilder
SetCollation sets the value for the Collation field.
func (*ChangeStreamOptionsBuilder) SetComment ¶
func (cso *ChangeStreamOptionsBuilder) SetComment(comment interface{}) *ChangeStreamOptionsBuilder
SetComment sets the value for the Comment field.
func (*ChangeStreamOptionsBuilder) SetCustom ¶
func (cso *ChangeStreamOptionsBuilder) SetCustom(c bson.M) *ChangeStreamOptionsBuilder
SetCustom sets the value for the Custom field. 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.
func (*ChangeStreamOptionsBuilder) SetCustomPipeline ¶
func (cso *ChangeStreamOptionsBuilder) SetCustomPipeline(cp bson.M) *ChangeStreamOptionsBuilder
SetCustomPipeline sets the value for the CustomPipeline field. 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.
func (*ChangeStreamOptionsBuilder) SetFullDocument ¶
func (cso *ChangeStreamOptionsBuilder) SetFullDocument(fd FullDocument) *ChangeStreamOptionsBuilder
SetFullDocument sets the value for the FullDocument field.
func (*ChangeStreamOptionsBuilder) SetFullDocumentBeforeChange ¶
func (cso *ChangeStreamOptionsBuilder) SetFullDocumentBeforeChange(fdbc FullDocument) *ChangeStreamOptionsBuilder
SetFullDocumentBeforeChange sets the value for the FullDocumentBeforeChange field.
func (*ChangeStreamOptionsBuilder) SetMaxAwaitTime ¶
func (cso *ChangeStreamOptionsBuilder) SetMaxAwaitTime(d time.Duration) *ChangeStreamOptionsBuilder
SetMaxAwaitTime sets the value for the MaxAwaitTime field.
func (*ChangeStreamOptionsBuilder) SetResumeAfter ¶
func (cso *ChangeStreamOptionsBuilder) SetResumeAfter(rt interface{}) *ChangeStreamOptionsBuilder
SetResumeAfter sets the value for the ResumeAfter field.
func (*ChangeStreamOptionsBuilder) SetShowExpandedEvents ¶
func (cso *ChangeStreamOptionsBuilder) SetShowExpandedEvents(see bool) *ChangeStreamOptionsBuilder
SetShowExpandedEvents sets the value for the ShowExpandedEvents field.
func (*ChangeStreamOptionsBuilder) SetStartAfter ¶
func (cso *ChangeStreamOptionsBuilder) SetStartAfter(sa interface{}) *ChangeStreamOptionsBuilder
SetStartAfter sets the value for the StartAfter field.
func (*ChangeStreamOptionsBuilder) SetStartAtOperationTime ¶
func (cso *ChangeStreamOptionsBuilder) SetStartAtOperationTime(t *bson.Timestamp) *ChangeStreamOptionsBuilder
SetStartAtOperationTime sets the value for the StartAtOperationTime field.
type ClientEncryptionOptions ¶
type ClientEncryptionOptions struct { KeyVaultNamespace string KmsProviders map[string]map[string]interface{} TLSConfig map[string]*tls.Config HTTPClient *http.Client }
ClientEncryptionOptions represents all possible arguments used to configure a ClientEncryption instance.
type ClientEncryptionOptionsBuilder ¶
type ClientEncryptionOptionsBuilder struct {
Opts []func(*ClientEncryptionOptions) error
}
ClientEncryptionOptionsBuilder contains options to configure client encryption operations. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func ClientEncryption ¶
func ClientEncryption() *ClientEncryptionOptionsBuilder
ClientEncryption creates a new ClientEncryptionOptions instance.
func (*ClientEncryptionOptionsBuilder) List ¶
func (c *ClientEncryptionOptionsBuilder) List() []func(*ClientEncryptionOptions) error
List returns a list of ClientEncryptionOptions setter functions.
func (*ClientEncryptionOptionsBuilder) SetKeyVaultNamespace ¶
func (c *ClientEncryptionOptionsBuilder) SetKeyVaultNamespace(ns string) *ClientEncryptionOptionsBuilder
SetKeyVaultNamespace specifies the namespace of the key vault collection. This is required.
func (*ClientEncryptionOptionsBuilder) SetKmsProviders ¶
func (c *ClientEncryptionOptionsBuilder) SetKmsProviders(providers map[string]map[string]interface{}) *ClientEncryptionOptionsBuilder
SetKmsProviders specifies options for KMS providers. This is required.
func (*ClientEncryptionOptionsBuilder) SetTLSConfig ¶
func (c *ClientEncryptionOptionsBuilder) SetTLSConfig(tlsOpts map[string]*tls.Config) *ClientEncryptionOptionsBuilder
SetTLSConfig specifies tls.Config instances for each KMS provider to use to configure TLS on all connections created to 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.
type ClientOptions ¶
type ClientOptions struct { AppName *string Auth *Credential AutoEncryptionOptions Lister[AutoEncryptionOptions] ConnectTimeout *time.Duration Compressors []string Dialer ContextDialer Direct *bool DisableOCSPEndpointCheck *bool HeartbeatInterval *time.Duration Hosts []string HTTPClient *http.Client LoadBalanced *bool LocalThreshold *time.Duration LoggerOptions Lister[LoggerOptions] MaxConnIdleTime *time.Duration MaxPoolSize *uint64 MinPoolSize *uint64 MaxConnecting *uint64 PoolMonitor *event.PoolMonitor Monitor *event.CommandMonitor ServerMonitor *event.ServerMonitor ReadConcern *readconcern.ReadConcern ReadPreference *readpref.ReadPref BSONOptions *BSONOptions Registry *bson.Registry ReplicaSet *string RetryReads *bool RetryWrites *bool ServerAPIOptions Lister[ServerAPIOptions] ServerMonitoringMode *string ServerSelectionTimeout *time.Duration SRVMaxHosts *int SRVServiceName *string Timeout *time.Duration TLSConfig *tls.Config WriteConcern *writeconcern.WriteConcern ZlibLevel *int ZstdLevel *int // 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. Crypt driver.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. Deployment driver.Deployment // contains filtered or unexported fields }
ClientOptions contains arguments to configure a Client instance. Arguments can be set through the ClientOptions setter functions. See each function for documentation.
func (*ClientOptions) GetURI ¶
func (opts *ClientOptions) GetURI() string
GetURI returns the original URI used to configure the ClientOptions instance. If ApplyURI was not called during construction, this returns "".
type ClientOptionsBuilder ¶
type ClientOptionsBuilder struct {
Opts []func(*ClientOptions) error
}
ClientOptionsBuilder contains options to configure a Client instance. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func (*ClientOptionsBuilder) ApplyURI ¶
func (c *ClientOptionsBuilder) ApplyURI(uri string) *ClientOptionsBuilder
ApplyURI parses the given URI and sets options accordingly. The URI can contain host names, IPv4/IPv6 literals, or an SRV record that will be resolved when the Client is created. When using an SRV record, TLS support is implicitly 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 that correspond to multiple URI parameters, such as WriteConcern, will be completely overwritten if any of the query parameters are specified. If an option is set on ClientOptions after this method is called, that option will override any 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 and can be retrieved by calling Validate.
For more information about the URI format, see https://www.mongodb.com/docs/manual/reference/connection-string/. See mongo.Connect documentation for examples of using URIs for different Client configurations.
func (*ClientOptionsBuilder) GetURI ¶
func (c *ClientOptionsBuilder) GetURI() string
GetURI returns the original URI used to configure the ClientOptions instance. If ApplyURI was not called during construction, this returns "".
func (*ClientOptionsBuilder) List ¶
func (c *ClientOptionsBuilder) List() []func(*ClientOptions) error
List returns a list of ClientOptions setter functions.
func (*ClientOptionsBuilder) SetAppName ¶
func (c *ClientOptionsBuilder) SetAppName(s string) *ClientOptionsBuilder
SetAppName specifies an application name that is sent to the server when creating new connections. It is used by the server 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 (*ClientOptionsBuilder) SetAuth ¶
func (c *ClientOptionsBuilder) SetAuth(auth Credential) *ClientOptionsBuilder
SetAuth specifies a Credential containing options for configuring authentication. See the options.Credential documentation for more information about Credential fields. The default is an empty Credential, meaning no authentication will be configured.
func (*ClientOptionsBuilder) SetAutoEncryptionOptions ¶
func (c *ClientOptionsBuilder) SetAutoEncryptionOptions(aeopts Lister[AutoEncryptionOptions]) *ClientOptionsBuilder
SetAutoEncryptionOptions specifies an AutoEncryptionOptions instance to automatically encrypt and decrypt commands and their results. See the options.AutoEncryptionOptions documentation for more information about the supported options.
func (*ClientOptionsBuilder) SetBSONOptions ¶
func (c *ClientOptionsBuilder) SetBSONOptions(bopts *BSONOptions) *ClientOptionsBuilder
SetBSONOptions configures optional BSON marshaling and unmarshaling behavior.
func (*ClientOptionsBuilder) SetCompressors ¶
func (c *ClientOptionsBuilder) SetCompressors(comps []string) *ClientOptionsBuilder
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 driver version >= 1.3.0 without cgo.
If this option is specified, the driver will perform a negotiation with the server to determine a common list of compressors and will use the first one in that list when performing operations. See https://www.mongodb.com/docs/manual/reference/program/mongod/#cmdoption-mongod-networkmessagecompressors for more information 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 is an empty slice, meaning no compression will be enabled.
func (*ClientOptionsBuilder) SetConnectTimeout ¶
func (c *ClientOptionsBuilder) SetConnectTimeout(d time.Duration) *ClientOptionsBuilder
SetConnectTimeout specifies a timeout that is used for creating connections to the server. This can be set through ApplyURI with the "connectTimeoutMS" (e.g "connectTimeoutMS=30") option. If set to 0, no timeout will be used. The default is 30 seconds.
func (*ClientOptionsBuilder) SetDialer ¶
func (c *ClientOptionsBuilder) SetDialer(d ContextDialer) *ClientOptionsBuilder
SetDialer specifies a custom ContextDialer to be used to create new connections to the server. This method overrides the default net.Dialer, so dialer options such as Timeout, KeepAlive, Resolver, etc can be set. See https://golang.org/pkg/net/#Dialer for more information about the net.Dialer type.
func (*ClientOptionsBuilder) SetDirect ¶
func (c *ClientOptionsBuilder) SetDirect(b bool) *ClientOptionsBuilder
SetDirect specifies whether or not a direct connect should be made. If set to true, the driver will only connect to the 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 through ApplyURI 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 must not conflict. Direct connections are not valid if multiple hosts are specified or an SRV URI is used. The default value for this option is false.
func (*ClientOptionsBuilder) SetDisableOCSPEndpointCheck ¶
func (c *ClientOptionsBuilder) SetDisableOCSPEndpointCheck(disableCheck bool) *ClientOptionsBuilder
SetDisableOCSPEndpointCheck specifies whether or not the driver should reach out to OCSP responders to verify the certificate 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 there is one, but will not send an HTTP request to any responders if there is no staple. In this case, the driver will continue 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 must not be set at the same time and will error if they are. The default value is false.
func (*ClientOptionsBuilder) SetHTTPClient ¶
func (c *ClientOptionsBuilder) SetHTTPClient(client *http.Client) *ClientOptionsBuilder
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 (*ClientOptionsBuilder) SetHeartbeatInterval ¶
func (c *ClientOptionsBuilder) SetHeartbeatInterval(d time.Duration) *ClientOptionsBuilder
SetHeartbeatInterval specifies the amount of time to wait between periodic background server checks. This can also be set through the "heartbeatIntervalMS" URI option (e.g. "heartbeatIntervalMS=10000"). The default is 10 seconds.
func (*ClientOptionsBuilder) SetHosts ¶
func (c *ClientOptionsBuilder) SetHosts(s []string) *ClientOptionsBuilder
SetHosts specifies a list of host names or IP addresses for servers in a cluster. Both IPv4 and IPv6 addresses are supported. 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 (*ClientOptionsBuilder) SetLoadBalanced ¶
func (c *ClientOptionsBuilder) SetLoadBalanced(lb bool) *ClientOptionsBuilder
SetLoadBalanced specifies whether or not the MongoDB deployment is hosted behind a load balancer. This can also be set through the "loadBalanced" URI option. The driver will error during Client configuration if this option is set to 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 SRV URI 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 (*ClientOptionsBuilder) SetLocalThreshold ¶
func (c *ClientOptionsBuilder) SetLocalThreshold(d time.Duration) *ClientOptionsBuilder
SetLocalThreshold specifies the width of the 'latency window': when choosing between multiple suitable servers for an operation, this is the acceptable non-negative delta between shortest and longest average round-trip times. A server within 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 (*ClientOptionsBuilder) SetLoggerOptions ¶
func (c *ClientOptionsBuilder) SetLoggerOptions(lopts Lister[LoggerOptions]) *ClientOptionsBuilder
SetLoggerOptions specifies a LoggerOptions containing options for configuring a logger.
Example (CustomLogger) ¶
package main import ( "bytes" "context" "fmt" "io" "log" "sync" "go.mongodb.org/mongo-driver/v2/mongo" "go.mongodb.org/mongo-driver/v2/mongo/options" ) type CustomLogger struct { io.Writer mu 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(clientOptions) if err != nil { log.Fatalf("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.Fatalf("InsertOne failed: %v", err) } // Print the logs. fmt.Println(buf.String()) }
Output:
func (*ClientOptionsBuilder) SetMaxConnIdleTime ¶
func (c *ClientOptionsBuilder) SetMaxConnIdleTime(d time.Duration) *ClientOptionsBuilder
SetMaxConnIdleTime specifies the maximum amount of time that a connection will remain idle in a connection pool before 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 (*ClientOptionsBuilder) SetMaxConnecting ¶
func (c *ClientOptionsBuilder) SetMaxConnecting(u uint64) *ClientOptionsBuilder
SetMaxConnecting specifies the maximum number of connections a connection pool may establish simultaneously. This can also be set through the "maxConnecting" URI option (e.g. "maxConnecting=2"). If this is 0, the default is used. The default is 2. Values greater than 100 are not recommended.
func (*ClientOptionsBuilder) SetMaxPoolSize ¶
func (c *ClientOptionsBuilder) SetMaxPoolSize(u uint64) *ClientOptionsBuilder
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 (*ClientOptionsBuilder) SetMinPoolSize ¶
func (c *ClientOptionsBuilder) SetMinPoolSize(u uint64) *ClientOptionsBuilder
SetMinPoolSize specifies the minimum number of connections allowed in the driver's connection pool to each server. If this is non-zero, each server's pool will be maintained in the background to ensure that the size does not fall below the minimum. This can also be set through the "minPoolSize" URI option (e.g. "minPoolSize=100"). The default is 0.
func (*ClientOptionsBuilder) SetMonitor ¶
func (c *ClientOptionsBuilder) SetMonitor(m *event.CommandMonitor) *ClientOptionsBuilder
SetMonitor specifies a CommandMonitor to receive command events. See the event.CommandMonitor documentation for more information about the structure of the monitor and events that can be received.
func (*ClientOptionsBuilder) SetPoolMonitor ¶
func (c *ClientOptionsBuilder) SetPoolMonitor(m *event.PoolMonitor) *ClientOptionsBuilder
SetPoolMonitor specifies a PoolMonitor to receive connection pool events. See the event.PoolMonitor documentation for more information about the structure of the monitor and events that can be received.
func (*ClientOptionsBuilder) SetReadConcern ¶
func (c *ClientOptionsBuilder) SetReadConcern(rc *readconcern.ReadConcern) *ClientOptionsBuilder
SetReadConcern specifies the read concern to use for read operations. A read concern level can also be set through the "readConcernLevel" URI option (e.g. "readConcernLevel=majority"). The default is nil, meaning the server will use its configured default.
func (*ClientOptionsBuilder) SetReadPreference ¶
func (c *ClientOptionsBuilder) SetReadPreference(rp *readpref.ReadPref) *ClientOptionsBuilder
SetReadPreference specifies the read preference to use for read operations. This can also be set through the following 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 a replica set (e.g. "maxStalenessSeconds=10").
The default is readpref.Primary(). See https://www.mongodb.com/docs/manual/core/read-preference/#read-preference for more information about read preferences.
func (*ClientOptionsBuilder) SetRegistry ¶
func (c *ClientOptionsBuilder) SetRegistry(registry *bson.Registry) *ClientOptionsBuilder
SetRegistry specifies the BSON registry to use for BSON marshalling/unmarshalling operations. The default is bson.DefaultRegistry.
func (*ClientOptionsBuilder) SetReplicaSet ¶
func (c *ClientOptionsBuilder) SetReplicaSet(s string) *ClientOptionsBuilder
SetReplicaSet specifies the replica set name for the cluster. If specified, the cluster will be treated as a replica set and the driver will automatically discover all servers in the set, starting with the nodes specified through ApplyURI or SetHosts. All nodes in the replica set must have the same replica set name, or they will not be considered 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 (*ClientOptionsBuilder) SetRetryReads ¶
func (c *ClientOptionsBuilder) SetRetryReads(b bool) *ClientOptionsBuilder
SetRetryReads specifies whether supported read operations should be retried once on certain errors, such as network errors.
Supported operations are Find, FindOne, Aggregate without a $out stage, Distinct, CountDocuments, EstimatedDocumentCount, Watch (for Client, Database, and Collection), ListCollections, and ListDatabases. Note that operations run through RunCommand are not retried.
This option requires server version >= 3.6 and driver version >= 1.1.0. The default is true.
func (*ClientOptionsBuilder) SetRetryWrites ¶
func (c *ClientOptionsBuilder) SetRetryWrites(b bool) *ClientOptionsBuilder
SetRetryWrites specifies whether supported write operations should be retried once on certain errors, such as network errors.
Supported operations are InsertOne, UpdateOne, ReplaceOne, DeleteOne, FindOneAndDelete, FindOneAndReplace, FindOneAndDelete, InsertMany, and BulkWrite. Note that BulkWrite requests must not include UpdateManyModel or DeleteManyModel instances to be considered retryable. Unacknowledged writes will not be retried, even if this option is set to true.
This option requires server version >= 3.6 and a replica set or sharded cluster and will be ignored for any other cluster type. This can also be set through the "retryWrites" URI option (e.g. "retryWrites=true"). The default is true.
func (*ClientOptionsBuilder) SetSRVMaxHosts ¶
func (c *ClientOptionsBuilder) SetSRVMaxHosts(srvMaxHosts int) *ClientOptionsBuilder
SetSRVMaxHosts specifies the maximum number of SRV results to randomly select during polling. To limit the number of hosts selected in SRV discovery, this function must be called before ApplyURI. This can also be set through the "srvMaxHosts" URI option.
func (*ClientOptionsBuilder) SetSRVServiceName ¶
func (c *ClientOptionsBuilder) SetSRVServiceName(srvName string) *ClientOptionsBuilder
SetSRVServiceName specifies a custom SRV service name to use in SRV polling. To use a custom SRV service name in SRV discovery, this function must be called before ApplyURI. This can also be set through the "srvServiceName" URI option.
func (*ClientOptionsBuilder) SetServerAPIOptions ¶
func (c *ClientOptionsBuilder) SetServerAPIOptions(sopts Lister[ServerAPIOptions]) *ClientOptionsBuilder
SetServerAPIOptions specifies a ServerAPIOptions instance used to configure the API version sent to the server when running commands. See the options.ServerAPIOptions documentation for more information about the supported options.
func (*ClientOptionsBuilder) SetServerMonitor ¶
func (c *ClientOptionsBuilder) SetServerMonitor(m *event.ServerMonitor) *ClientOptionsBuilder
SetServerMonitor specifies an SDAM monitor used to monitor SDAM events.
func (*ClientOptionsBuilder) SetServerMonitoringMode ¶
func (c *ClientOptionsBuilder) SetServerMonitoringMode(mode string) *ClientOptionsBuilder
SetServerMonitoringMode specifies the server monitoring protocol to use. See the helper constants ServerMonitoringModeAuto, ServerMonitoringModePoll, and ServerMonitoringModeStream for more information about valid server monitoring modes.
func (*ClientOptionsBuilder) SetServerSelectionTimeout ¶
func (c *ClientOptionsBuilder) SetServerSelectionTimeout(d time.Duration) *ClientOptionsBuilder
SetServerSelectionTimeout specifies how long the driver will wait to find an available, suitable server to execute an operation. This can also be set through the "serverSelectionTimeoutMS" URI option (e.g. "serverSelectionTimeoutMS=30000"). The default value is 30 seconds.
func (*ClientOptionsBuilder) SetTLSConfig ¶
func (c *ClientOptionsBuilder) SetTLSConfig(cfg *tls.Config) *ClientOptionsBuilder
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 separate paths to the client certificate and private key, respectively. Note that if "tlsCertificateKeyFile" is used, the other two options must not be specified. Only the subject name of the first certificate is honored as the username for X509 auth in a file with multiple certs.
3. "tlsCertificateKeyFilePassword" (or "sslClientCertificateKeyPassword"): Specify the password to decrypt the client private key file (e.g. "tlsCertificateKeyFilePassword=password").
4. "tlsCaFile" (or "sslCertificateAuthorityFile"): Specify the path to a single or bundle of certificate authorities to 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 server should be validated. If true (e.g. "tlsInsecure=true"), the TLS library will accept any certificate presented by the server and any host name in that certificate. Note that setting this to true makes TLS susceptible to man-in-the-middle attacks and should only be done for testing.
The default is nil, meaning no TLS will be enabled.
func (*ClientOptionsBuilder) SetTimeout ¶
func (c *ClientOptionsBuilder) SetTimeout(d time.Duration) *ClientOptionsBuilder
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 only be 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 and SessionOptions.DefaultMaxCommitTime will be ignored.
func (*ClientOptionsBuilder) SetWriteConcern ¶
func (c *ClientOptionsBuilder) SetWriteConcern(wc *writeconcern.WriteConcern) *ClientOptionsBuilder
SetWriteConcern specifies the write concern to use to for write operations. This can also be set through the following URI options:
1. "w": Specify the number of nodes in the cluster that must acknowledge write operations before the operation returns 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 the operation (e.g. "wTimeoutMS=1000").
3. "journal": Specifies whether or not write operations should be written to an on-disk journal on the server before returning (e.g. "journal=true").
The default is nil, meaning the server will use its configured default.
func (*ClientOptionsBuilder) SetZlibLevel ¶
func (c *ClientOptionsBuilder) SetZlibLevel(level int) *ClientOptionsBuilder
SetZlibLevel specifies the level for the zlib compressor. This option is ignored if zlib is not specified as a compressor through ApplyURI or SetCompressors. Supported values are -1 through 9, inclusive. -1 tells the zlib library 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 (*ClientOptionsBuilder) SetZstdLevel ¶
func (c *ClientOptionsBuilder) SetZstdLevel(level int) *ClientOptionsBuilder
SetZstdLevel sets the level for the zstd compressor. This option is ignored if zstd is not specified as a compressor through ApplyURI or SetCompressors. Supported values are 1 through 20, inclusive. 1 means best speed and 20 means best compression. This can also be set through the "zstdCompressionLevel" URI option. Defaults to 6.
func (*ClientOptionsBuilder) Validate ¶
func (c *ClientOptionsBuilder) Validate() error
Validate validates the client options. This method will return the first error found.
type Collation ¶
type Collation struct { Locale string `bson:",omitempty"` // The locale CaseLevel bool `bson:",omitempty"` // The case level CaseFirst string `bson:",omitempty"` // The case ordering Strength int `bson:",omitempty"` // The number of comparison levels to use NumericOrdering bool `bson:",omitempty"` // Whether to order numbers based on numerical order and not collation order Alternate string `bson:",omitempty"` // Whether spaces and punctuation are considered base characters MaxVariable string `bson:",omitempty"` // Which characters are affected by alternate: "shifted" Normalization bool `bson:",omitempty"` // Causes text to be normalized into Unicode NFD Backwards bool `bson:",omitempty"` // Causes secondary differences to be considered in reverse order, as it is done in the French language }
Collation allows users to specify language-specific rules for string comparison, such as rules for lettercase and accent marks.
func (*Collation) ToDocument
deprecated
type CollectionOptions ¶
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 *bson.Registry }
CollectionOptions represents arguments that can be used to configure a Collection.
type CollectionOptionsBuilder ¶
type CollectionOptionsBuilder struct {
Opts []func(*CollectionOptions) error
}
CollectionOptionsBuilder contains options to configure a Collection instance. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func Collection ¶
func Collection() *CollectionOptionsBuilder
Collection creates a new CollectionOptions instance.
func (*CollectionOptionsBuilder) List ¶
func (c *CollectionOptionsBuilder) List() []func(*CollectionOptions) error
List returns a list of CollectionOptions setter functions.
func (*CollectionOptionsBuilder) SetBSONOptions ¶
func (c *CollectionOptionsBuilder) SetBSONOptions(bopts *BSONOptions) *CollectionOptionsBuilder
SetBSONOptions configures optional BSON marshaling and unmarshaling behavior.
func (*CollectionOptionsBuilder) SetReadConcern ¶
func (c *CollectionOptionsBuilder) SetReadConcern(rc *readconcern.ReadConcern) *CollectionOptionsBuilder
SetReadConcern sets the value for the ReadConcern field.
func (*CollectionOptionsBuilder) SetReadPreference ¶
func (c *CollectionOptionsBuilder) SetReadPreference(rp *readpref.ReadPref) *CollectionOptionsBuilder
SetReadPreference sets the value for the ReadPreference field.
func (*CollectionOptionsBuilder) SetRegistry ¶
func (c *CollectionOptionsBuilder) SetRegistry(r *bson.Registry) *CollectionOptionsBuilder
SetRegistry sets the value for the Registry field.
func (*CollectionOptionsBuilder) SetWriteConcern ¶
func (c *CollectionOptionsBuilder) SetWriteConcern(wc *writeconcern.WriteConcern) *CollectionOptionsBuilder
SetWriteConcern sets the value for the WriteConcern field.
type ContextDialer ¶
type ContextDialer interface {
DialContext(ctx context.Context, network, address string) (net.Conn, error)
}
ContextDialer is an interface that can be implemented by types that can create connections. It should be used to provide a custom dialer when configuring a Client.
DialContext should return a connection to the provided address on the given network.
type CountOptions ¶
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 interface{} // The index to use for the aggregation. This should either be the index name as a string or the index specification // as a document. The 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 number of documents to skip before counting. The default value is 0. Skip *int64 }
CountOptions represents arguments that can be used to configure a CountDocuments operation.
type CountOptionsBuilder ¶
type CountOptionsBuilder struct {
Opts []func(*CountOptions) error
}
CountOptionsBuilder contains options to configure count operations. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func (*CountOptionsBuilder) List ¶
func (co *CountOptionsBuilder) List() []func(*CountOptions) error
List returns a list of CountOptions setter functions.
func (*CountOptionsBuilder) SetCollation ¶
func (co *CountOptionsBuilder) SetCollation(c *Collation) *CountOptionsBuilder
SetCollation sets the value for the Collation field.
func (*CountOptionsBuilder) SetComment ¶
func (co *CountOptionsBuilder) SetComment(comment interface{}) *CountOptionsBuilder
SetComment sets the value for the Comment field.
func (*CountOptionsBuilder) SetHint ¶
func (co *CountOptionsBuilder) SetHint(h interface{}) *CountOptionsBuilder
SetHint sets the value for the Hint field.
func (*CountOptionsBuilder) SetLimit ¶
func (co *CountOptionsBuilder) SetLimit(i int64) *CountOptionsBuilder
SetLimit sets the value for the Limit field.
func (*CountOptionsBuilder) SetSkip ¶
func (co *CountOptionsBuilder) SetSkip(i int64) *CountOptionsBuilder
SetSkip sets the value for the Skip field.
type CreateCollectionOptions ¶
type CreateCollectionOptions struct { // Specifies if the collection is capped (see https://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 *DefaultIndexOptionsBuilder // 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". See https://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.0 ExpireAfterSeconds *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.0 TimeSeriesOptions *TimeSeriesOptionsBuilder // EncryptedFields configures encrypted fields. // // This option is only valid for MongoDB versions >= 6.0 EncryptedFields interface{} // ClusteredIndex is used to create a collection with a clustered index. // // This option is only valid for MongoDB versions >= 5.3 ClusteredIndex interface{} }
CreateCollectionOptions represents arguments that can be used to configure a CreateCollection operation.
type CreateCollectionOptionsBuilder ¶
type CreateCollectionOptionsBuilder struct {
Opts []func(*CreateCollectionOptions) error
}
CreateCollectionOptionsBuilder contains options to configure a new collection. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func CreateCollection ¶
func CreateCollection() *CreateCollectionOptionsBuilder
CreateCollection creates a new CreateCollectionOptions instance.
func (*CreateCollectionOptionsBuilder) List ¶
func (c *CreateCollectionOptionsBuilder) List() []func(*CreateCollectionOptions) error
List returns a list of CreateCollectionOptions setter functions.
func (*CreateCollectionOptionsBuilder) SetCapped ¶
func (c *CreateCollectionOptionsBuilder) SetCapped(capped bool) *CreateCollectionOptionsBuilder
SetCapped sets the value for the Capped field.
func (*CreateCollectionOptionsBuilder) SetChangeStreamPreAndPostImages ¶
func (c *CreateCollectionOptionsBuilder) SetChangeStreamPreAndPostImages(csppi interface{}) *CreateCollectionOptionsBuilder
SetChangeStreamPreAndPostImages sets the value for the ChangeStreamPreAndPostImages field.
func (*CreateCollectionOptionsBuilder) SetClusteredIndex ¶
func (c *CreateCollectionOptionsBuilder) SetClusteredIndex(clusteredIndex interface{}) *CreateCollectionOptionsBuilder
SetClusteredIndex sets the value for the ClusteredIndex field.
func (*CreateCollectionOptionsBuilder) SetCollation ¶
func (c *CreateCollectionOptionsBuilder) SetCollation(collation *Collation) *CreateCollectionOptionsBuilder
SetCollation sets the value for the Collation field.
func (*CreateCollectionOptionsBuilder) SetDefaultIndexOptions ¶
func (c *CreateCollectionOptionsBuilder) SetDefaultIndexOptions(iopts *DefaultIndexOptionsBuilder) *CreateCollectionOptionsBuilder
SetDefaultIndexOptions sets the value for the DefaultIndexOptions field.
func (*CreateCollectionOptionsBuilder) SetEncryptedFields ¶
func (c *CreateCollectionOptionsBuilder) SetEncryptedFields(encryptedFields interface{}) *CreateCollectionOptionsBuilder
SetEncryptedFields sets the encrypted fields for encrypted collections.
func (*CreateCollectionOptionsBuilder) SetExpireAfterSeconds ¶
func (c *CreateCollectionOptionsBuilder) SetExpireAfterSeconds(eas int64) *CreateCollectionOptionsBuilder
SetExpireAfterSeconds sets the value for the ExpireAfterSeconds field.
func (*CreateCollectionOptionsBuilder) SetMaxDocuments ¶
func (c *CreateCollectionOptionsBuilder) SetMaxDocuments(max int64) *CreateCollectionOptionsBuilder
SetMaxDocuments sets the value for the MaxDocuments field.
func (*CreateCollectionOptionsBuilder) SetSizeInBytes ¶
func (c *CreateCollectionOptionsBuilder) SetSizeInBytes(size int64) *CreateCollectionOptionsBuilder
SetSizeInBytes sets the value for the SizeInBytes field.
func (*CreateCollectionOptionsBuilder) SetStorageEngine ¶
func (c *CreateCollectionOptionsBuilder) SetStorageEngine(storageEngine interface{}) *CreateCollectionOptionsBuilder
SetStorageEngine sets the value for the StorageEngine field.
func (*CreateCollectionOptionsBuilder) SetTimeSeriesOptions ¶
func (c *CreateCollectionOptionsBuilder) SetTimeSeriesOptions(timeSeriesOpts *TimeSeriesOptionsBuilder) *CreateCollectionOptionsBuilder
SetTimeSeriesOptions sets the options for time-series collections.
func (*CreateCollectionOptionsBuilder) SetValidationAction ¶
func (c *CreateCollectionOptionsBuilder) SetValidationAction(action string) *CreateCollectionOptionsBuilder
SetValidationAction sets the value for the ValidationAction field.
func (*CreateCollectionOptionsBuilder) SetValidationLevel ¶
func (c *CreateCollectionOptionsBuilder) SetValidationLevel(level string) *CreateCollectionOptionsBuilder
SetValidationLevel sets the value for the ValidationLevel field.
func (*CreateCollectionOptionsBuilder) SetValidator ¶
func (c *CreateCollectionOptionsBuilder) SetValidator(validator interface{}) *CreateCollectionOptionsBuilder
SetValidator sets the value for the Validator field.
type CreateIndexesOptions ¶
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{} }
CreateIndexesOptions represents arguments that can be used to configure IndexView.CreateOne and IndexView.CreateMany operations.
type CreateIndexesOptionsBuilder ¶
type CreateIndexesOptionsBuilder struct {
Opts []func(*CreateIndexesOptions) error
}
CreateIndexesOptionsBuilder contains options to create indexes. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func CreateIndexes ¶
func CreateIndexes() *CreateIndexesOptionsBuilder
CreateIndexes creates a new CreateIndexesOptions instance.
func (*CreateIndexesOptionsBuilder) List ¶
func (c *CreateIndexesOptionsBuilder) List() []func(*CreateIndexesOptions) error
List returns a list of CreateIndexesOptions setter functions.
func (*CreateIndexesOptionsBuilder) SetCommitQuorumInt ¶
func (c *CreateIndexesOptionsBuilder) SetCommitQuorumInt(quorum int32) *CreateIndexesOptionsBuilder
SetCommitQuorumInt sets the value for the CommitQuorum field as an int32.
func (*CreateIndexesOptionsBuilder) SetCommitQuorumMajority ¶
func (c *CreateIndexesOptionsBuilder) SetCommitQuorumMajority() *CreateIndexesOptionsBuilder
SetCommitQuorumMajority sets the value for the CommitQuorum to special "majority" value.
func (*CreateIndexesOptionsBuilder) SetCommitQuorumString ¶
func (c *CreateIndexesOptionsBuilder) SetCommitQuorumString(quorum string) *CreateIndexesOptionsBuilder
SetCommitQuorumString sets the value for the CommitQuorum field as a string.
func (*CreateIndexesOptionsBuilder) SetCommitQuorumVotingMembers ¶
func (c *CreateIndexesOptionsBuilder) SetCommitQuorumVotingMembers() *CreateIndexesOptionsBuilder
SetCommitQuorumVotingMembers sets the value for the CommitQuorum to special "votingMembers" value.
type CreateSearchIndexesOptions ¶
type CreateSearchIndexesOptions struct{}
CreateSearchIndexesOptions represents arguments that can be used to configure a SearchIndexView.CreateOne or SearchIndexView.CreateMany operation.
type CreateSearchIndexesOptionsBuilder ¶
type CreateSearchIndexesOptionsBuilder struct {
Opts []func(*CreateSearchIndexesOptions) error
}
CreateSearchIndexesOptionsBuilder contains options to configure creating search indexes. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func (*CreateSearchIndexesOptionsBuilder) List ¶
func (csio *CreateSearchIndexesOptionsBuilder) List() []func(*CreateSearchIndexesOptions) error
List returns a list of CreateSearchIndexesOptions setter functions.
type CreateViewOptions ¶
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 arguments that can be used to configure a CreateView operation.
type CreateViewOptionsBuilder ¶
type CreateViewOptionsBuilder struct {
Opts []func(*CreateViewOptions) error
}
CreateViewOptionsBuilder contains options to configure a new view. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func CreateView ¶
func CreateView() *CreateViewOptionsBuilder
CreateView creates an new CreateViewOptions instance.
func (*CreateViewOptionsBuilder) List ¶
func (c *CreateViewOptionsBuilder) List() []func(*CreateViewOptions) error
List returns a list of TimeSeriesOptions setter functions.
func (*CreateViewOptionsBuilder) SetCollation ¶
func (c *CreateViewOptionsBuilder) SetCollation(collation *Collation) *CreateViewOptionsBuilder
SetCollation sets the value for the Collation field.
type Credential ¶
type Credential struct { AuthMechanism string AuthMechanismProperties map[string]string AuthSource string Username string Password string PasswordSet bool }
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, see https://www.mongodb.com/docs/manual/core/authentication-mechanisms/.
AuthMechanismProperties can be used to specify additional configuration options for certain mechanisms. They can also be 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 default is "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 for authentication 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 with temporary credentials.
The SERVICE_HOST and CANONICALIZE_HOST_NAME properties must not be used at the same time on Linux and Darwin systems.
AuthSource: the name of the database to use for authentication. This defaults to "$external" for MONGODB-X509, GSSAPI, and PLAIN and "admin" for all other mechanisms. This can also 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 before the 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 the client certificate if not specified.
Password: the password for authentication. This must not be specified for X509 and is optional for GSSAPI authentication.
PasswordSet: For GSSAPI, this must be true if a password is specified, even if the password is the empty string, and false if no password is specified, indicating that the password should be taken from the context of the running process. For other mechanisms, this field is ignored.
type CursorType ¶
type CursorType int8
CursorType specifies whether a cursor should close when the last data is retrieved. See NonTailable, Tailable, and TailableAwait.
const ( // NonTailable specifies that a cursor should close after retrieving the last data. NonTailable CursorType = iota // Tailable specifies that a cursor should not close when the last data is retrieved and can be resumed later. Tailable // TailableAwait specifies that a cursor should not close when the last data is retrieved and // that it should block for a certain amount of time for new data before returning no data. TailableAwait )
type DataKeyOptions ¶
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.
type DataKeyOptionsBuilder ¶
type DataKeyOptionsBuilder struct {
Opts []func(*DataKeyOptions) error
}
DataKeyOptionsBuilder contains options to configure DataKey operations. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func (*DataKeyOptionsBuilder) List ¶
func (dk *DataKeyOptionsBuilder) List() []func(*DataKeyOptions) error
List returns a list of DataKey setter functions.
func (*DataKeyOptionsBuilder) SetKeyAltNames ¶
func (dk *DataKeyOptionsBuilder) SetKeyAltNames(keyAltNames []string) *DataKeyOptionsBuilder
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 (*DataKeyOptionsBuilder) SetKeyMaterial ¶
func (dk *DataKeyOptionsBuilder) SetKeyMaterial(keyMaterial []byte) *DataKeyOptionsBuilder
SetKeyMaterial will set a custom keyMaterial to DataKeyOptions which can be used to encrypt data.
func (*DataKeyOptionsBuilder) SetMasterKey ¶
func (dk *DataKeyOptionsBuilder) SetMasterKey(masterKey interface{}) *DataKeyOptionsBuilder
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".
type DatabaseOptions ¶
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 *bson.Registry }
DatabaseOptions represents arguments that can be used to configure a database.
type DatabaseOptionsBuilder ¶
type DatabaseOptionsBuilder struct {
Opts []func(*DatabaseOptions) error
}
DatabaseOptionsBuilder contains options to configure a database object. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func Database ¶
func Database() *DatabaseOptionsBuilder
Database creates a new DatabaseOptions instance.
func (*DatabaseOptionsBuilder) List ¶
func (d *DatabaseOptionsBuilder) List() []func(*DatabaseOptions) error
List returns a list of DatabaseOptions setter functions.
func (*DatabaseOptionsBuilder) SetBSONOptions ¶
func (d *DatabaseOptionsBuilder) SetBSONOptions(bopts *BSONOptions) *DatabaseOptionsBuilder
SetBSONOptions configures optional BSON marshaling and unmarshaling behavior.
func (*DatabaseOptionsBuilder) SetReadConcern ¶
func (d *DatabaseOptionsBuilder) SetReadConcern(rc *readconcern.ReadConcern) *DatabaseOptionsBuilder
SetReadConcern sets the value for the ReadConcern field.
func (*DatabaseOptionsBuilder) SetReadPreference ¶
func (d *DatabaseOptionsBuilder) SetReadPreference(rp *readpref.ReadPref) *DatabaseOptionsBuilder
SetReadPreference sets the value for the ReadPreference field.
func (*DatabaseOptionsBuilder) SetRegistry ¶
func (d *DatabaseOptionsBuilder) SetRegistry(r *bson.Registry) *DatabaseOptionsBuilder
SetRegistry sets the value for the Registry field.
func (*DatabaseOptionsBuilder) SetWriteConcern ¶
func (d *DatabaseOptionsBuilder) SetWriteConcern(wc *writeconcern.WriteConcern) *DatabaseOptionsBuilder
SetWriteConcern sets the value for the WriteConcern field.
type DefaultIndexOptions ¶
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 arguments for a collection to apply on new indexes. This type can be used when creating a new collection through the CreateCollectionOptions.SetDefaultIndexOptions method.
type DefaultIndexOptionsBuilder ¶
type DefaultIndexOptionsBuilder struct {
Opts []func(*DefaultIndexOptions) error
}
DefaultIndexOptionsBuilder contains options to configure default index operations. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func DefaultIndex ¶
func DefaultIndex() *DefaultIndexOptionsBuilder
DefaultIndex creates a new DefaultIndexOptions instance.
func (*DefaultIndexOptionsBuilder) List ¶
func (d *DefaultIndexOptionsBuilder) List() []func(*DefaultIndexOptions) error
List returns a list of DefaultIndexOptions setter functions.
func (*DefaultIndexOptionsBuilder) SetStorageEngine ¶
func (d *DefaultIndexOptionsBuilder) SetStorageEngine(storageEngine interface{}) *DefaultIndexOptionsBuilder
SetStorageEngine sets the value for the StorageEngine field.
type DeleteOptions ¶
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 arguments that can be used to configure DeleteOne and DeleteMany operations.
type DeleteOptionsBuilder ¶
type DeleteOptionsBuilder struct {
Opts []func(*DeleteOptions) error
}
DeleteOptionsBuilder contains options to configure delete operations. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func (*DeleteOptionsBuilder) List ¶
func (do *DeleteOptionsBuilder) List() []func(*DeleteOptions) error
List returns a list of DeleteOptions setter functions.
func (*DeleteOptionsBuilder) SetCollation ¶
func (do *DeleteOptionsBuilder) SetCollation(c *Collation) *DeleteOptionsBuilder
SetCollation sets the value for the Collation field.
func (*DeleteOptionsBuilder) SetComment ¶
func (do *DeleteOptionsBuilder) SetComment(comment interface{}) *DeleteOptionsBuilder
SetComment sets the value for the Comment field.
func (*DeleteOptionsBuilder) SetHint ¶
func (do *DeleteOptionsBuilder) SetHint(hint interface{}) *DeleteOptionsBuilder
SetHint sets the value for the Hint field.
func (*DeleteOptionsBuilder) SetLet ¶
func (do *DeleteOptionsBuilder) SetLet(let interface{}) *DeleteOptionsBuilder
SetLet sets the value for the Let field.
type DistinctOptions ¶
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{} }
DistinctOptions represents arguments that can be used to configure a Distinct operation.
type DistinctOptionsBuilder ¶
type DistinctOptionsBuilder struct {
Opts []func(*DistinctOptions) error
}
DistinctOptionsBuilder contains options to configure distinct operations. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func Distinct ¶
func Distinct() *DistinctOptionsBuilder
Distinct creates a new DistinctOptions instance.
func (*DistinctOptionsBuilder) List ¶
func (do *DistinctOptionsBuilder) List() []func(*DistinctOptions) error
List returns a list of DistinctArg setter functions.
func (*DistinctOptionsBuilder) SetCollation ¶
func (do *DistinctOptionsBuilder) SetCollation(c *Collation) *DistinctOptionsBuilder
SetCollation sets the value for the Collation field.
func (*DistinctOptionsBuilder) SetComment ¶
func (do *DistinctOptionsBuilder) SetComment(comment interface{}) *DistinctOptionsBuilder
SetComment sets the value for the Comment field.
type DropCollectionOptions ¶
type DropCollectionOptions struct { // EncryptedFields configures encrypted fields for encrypted collections. // // This option is only valid for MongoDB versions >= 6.0 EncryptedFields interface{} }
DropCollectionOptions represents arguments that can be used to configure a Drop operation.
type DropCollectionOptionsBuilder ¶
type DropCollectionOptionsBuilder struct {
Opts []func(*DropCollectionOptions) error
}
DropCollectionOptionsBuilder contains options to configure collection drop operations. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func DropCollection ¶
func DropCollection() *DropCollectionOptionsBuilder
DropCollection creates a new DropCollectionOptions instance.
func (*DropCollectionOptionsBuilder) List ¶
func (d *DropCollectionOptionsBuilder) List() []func(*DropCollectionOptions) error
List returns a list of DropCollectionOptions setter functions.
func (*DropCollectionOptionsBuilder) SetEncryptedFields ¶
func (d *DropCollectionOptionsBuilder) SetEncryptedFields(encryptedFields interface{}) *DropCollectionOptionsBuilder
SetEncryptedFields sets the encrypted fields for encrypted collections.
type DropIndexesOptions ¶
type DropIndexesOptions struct{}
DropIndexesOptions represents arguments that can be used to configure IndexView.DropOne and IndexView.DropAll operations.
type DropIndexesOptionsBuilder ¶
type DropIndexesOptionsBuilder struct {
Opts []func(*DropIndexesOptions) error
}
DropIndexesOptionsBuilder contains options to configure dropping indexes. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func DropIndexes ¶
func DropIndexes() *DropIndexesOptionsBuilder
DropIndexes creates a new DropIndexesOptions instance.
func (*DropIndexesOptionsBuilder) List ¶
func (d *DropIndexesOptionsBuilder) List() []func(*DropIndexesOptions) error
List returns a list of DropIndexesOptions setter functions.
type DropSearchIndexOptions ¶
type DropSearchIndexOptions struct{}
DropSearchIndexOptions represents arguments that can be used to configure a SearchIndexView.DropOne operation.
type DropSearchIndexOptionsBuilder ¶
type DropSearchIndexOptionsBuilder struct {
Opts []func(*DropSearchIndexOptions) error
}
DropSearchIndexOptionsBuilder contains options to configure dropping search indexes. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func (*DropSearchIndexOptionsBuilder) List ¶
func (dsio *DropSearchIndexOptionsBuilder) List() []func(*DropSearchIndexOptions) error
List returns a list of DropSearchIndexOptions setter functions.
type EncryptOptions ¶
type EncryptOptions struct { KeyID *bson.Binary KeyAltName *string Algorithm string QueryType string ContentionFactor *int64 RangeOptions *RangeOptionsBuilder }
EncryptOptions represents arguments to explicitly encrypt a value.
type EncryptOptionsBuilder ¶
type EncryptOptionsBuilder struct {
Opts []func(*EncryptOptions) error
}
EncryptOptionsBuilder contains options to configure Encryptopts for queryeable encryption. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func (*EncryptOptionsBuilder) List ¶
func (e *EncryptOptionsBuilder) List() []func(*EncryptOptions) error
List returns a list of EncryptOptions setter functions.
func (*EncryptOptionsBuilder) SetAlgorithm ¶
func (e *EncryptOptionsBuilder) SetAlgorithm(algorithm string) *EncryptOptionsBuilder
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 This is required. Indexed and Unindexed are used for Queryable Encryption.
func (*EncryptOptionsBuilder) SetContentionFactor ¶
func (e *EncryptOptionsBuilder) SetContentionFactor(contentionFactor int64) *EncryptOptionsBuilder
SetContentionFactor specifies the contention factor. It is only valid to set if algorithm is "Indexed". ContentionFactor is used for Queryable Encryption.
func (*EncryptOptionsBuilder) SetKeyAltName ¶
func (e *EncryptOptionsBuilder) SetKeyAltName(keyAltName string) *EncryptOptionsBuilder
SetKeyAltName identifies a key vault document by 'keyAltName'.
func (*EncryptOptionsBuilder) SetKeyID ¶
func (e *EncryptOptionsBuilder) SetKeyID(keyID bson.Binary) *EncryptOptionsBuilder
SetKeyID specifies an _id of a data key. This should be a UUID (a primitive.Binary with subtype 4).
func (*EncryptOptionsBuilder) SetQueryType ¶
func (e *EncryptOptionsBuilder) SetQueryType(queryType string) *EncryptOptionsBuilder
SetQueryType specifies the intended query type. It is only valid to set if algorithm is "Indexed". This should be one of the following: - equality QueryType is used for Queryable Encryption.
func (*EncryptOptionsBuilder) SetRangeOptions ¶
func (e *EncryptOptionsBuilder) SetRangeOptions(ro *RangeOptionsBuilder) *EncryptOptionsBuilder
SetRangeOptions specifies the options to use for explicit encryption with range. It is only valid to set if algorithm is "rangePreview". Beta: The Range algorithm is experimental only. It is not intended for public use. It is subject to breaking changes.
type EstimatedDocumentCountOptions ¶
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{} }
EstimatedDocumentCountOptions represents arguments that can be used to configure an EstimatedDocumentCount operation.
type EstimatedDocumentCountOptionsBuilder ¶
type EstimatedDocumentCountOptionsBuilder struct {
Opts []func(*EstimatedDocumentCountOptions) error
}
EstimatedDocumentCountOptionsBuilder contains options to estimate document count. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func EstimatedDocumentCount ¶
func EstimatedDocumentCount() *EstimatedDocumentCountOptionsBuilder
EstimatedDocumentCount creates a new EstimatedDocumentCountOptions instance.
func (*EstimatedDocumentCountOptionsBuilder) List ¶
func (eco *EstimatedDocumentCountOptionsBuilder) List() []func(*EstimatedDocumentCountOptions) error
List returns a list of CountOptions setter functions.
func (*EstimatedDocumentCountOptionsBuilder) SetComment ¶
func (eco *EstimatedDocumentCountOptionsBuilder) SetComment(comment interface{}) *EstimatedDocumentCountOptionsBuilder
SetComment sets the value for the Comment field.
type FindOneAndDeleteOptions ¶
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{} // 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 arguments that can be used to configure a FindOneAndDelete operation.
type FindOneAndDeleteOptionsBuilder ¶
type FindOneAndDeleteOptionsBuilder struct {
Opts []func(*FindOneAndDeleteOptions) error
}
FindOneAndDeleteOptionsBuilder contains options to configure delete operations. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func FindOneAndDelete ¶
func FindOneAndDelete() *FindOneAndDeleteOptionsBuilder
FindOneAndDelete creates a new FindOneAndDeleteOptions instance.
func (*FindOneAndDeleteOptionsBuilder) List ¶
func (f *FindOneAndDeleteOptionsBuilder) List() []func(*FindOneAndDeleteOptions) error
List returns a list of FindOneAndDeleteOptions setter functions.
func (*FindOneAndDeleteOptionsBuilder) SetCollation ¶
func (f *FindOneAndDeleteOptionsBuilder) SetCollation(collation *Collation) *FindOneAndDeleteOptionsBuilder
SetCollation sets the value for the Collation field.
func (*FindOneAndDeleteOptionsBuilder) SetComment ¶
func (f *FindOneAndDeleteOptionsBuilder) SetComment(comment interface{}) *FindOneAndDeleteOptionsBuilder
SetComment sets the value for the Comment field.
func (*FindOneAndDeleteOptionsBuilder) SetHint ¶
func (f *FindOneAndDeleteOptionsBuilder) SetHint(hint interface{}) *FindOneAndDeleteOptionsBuilder
SetHint sets the value for the Hint field.
func (*FindOneAndDeleteOptionsBuilder) SetLet ¶
func (f *FindOneAndDeleteOptionsBuilder) SetLet(let interface{}) *FindOneAndDeleteOptionsBuilder
SetLet sets the value for the Let field.
func (*FindOneAndDeleteOptionsBuilder) SetProjection ¶
func (f *FindOneAndDeleteOptionsBuilder) SetProjection(projection interface{}) *FindOneAndDeleteOptionsBuilder
SetProjection sets the value for the Projection field.
func (*FindOneAndDeleteOptionsBuilder) SetSort ¶
func (f *FindOneAndDeleteOptionsBuilder) SetSort(sort interface{}) *FindOneAndDeleteOptionsBuilder
SetSort sets the value for the Sort field.
type FindOneAndReplaceOptions ¶
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. See https://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{} // 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{} }
FindOneAndReplaceOptions represents arguments that can be used to configure a FindOneAndReplace instance.
type FindOneAndReplaceOptionsBuilder ¶
type FindOneAndReplaceOptionsBuilder struct {
Opts []func(*FindOneAndReplaceOptions) error
}
FindOneAndReplaceOptionsBuilder contains options to perform a findAndModify operation. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func FindOneAndReplace ¶
func FindOneAndReplace() *FindOneAndReplaceOptionsBuilder
FindOneAndReplace creates a new FindOneAndReplaceOptions instance.
func (*FindOneAndReplaceOptionsBuilder) List ¶
func (f *FindOneAndReplaceOptionsBuilder) List() []func(*FindOneAndReplaceOptions) error
List returns a list of FindOneAndReplaceOptions setter functions.
func (*FindOneAndReplaceOptionsBuilder) SetBypassDocumentValidation ¶
func (f *FindOneAndReplaceOptionsBuilder) SetBypassDocumentValidation(b bool) *FindOneAndReplaceOptionsBuilder
SetBypassDocumentValidation sets the value for the BypassDocumentValidation field.
func (*FindOneAndReplaceOptionsBuilder) SetCollation ¶
func (f *FindOneAndReplaceOptionsBuilder) SetCollation(collation *Collation) *FindOneAndReplaceOptionsBuilder
SetCollation sets the value for the Collation field.
func (*FindOneAndReplaceOptionsBuilder) SetComment ¶
func (f *FindOneAndReplaceOptionsBuilder) SetComment(comment interface{}) *FindOneAndReplaceOptionsBuilder
SetComment sets the value for the Comment field.
func (*FindOneAndReplaceOptionsBuilder) SetHint ¶
func (f *FindOneAndReplaceOptionsBuilder) SetHint(hint interface{}) *FindOneAndReplaceOptionsBuilder
SetHint sets the value for the Hint field.
func (*FindOneAndReplaceOptionsBuilder) SetLet ¶
func (f *FindOneAndReplaceOptionsBuilder) SetLet(let interface{}) *FindOneAndReplaceOptionsBuilder
SetLet sets the value for the Let field.
func (*FindOneAndReplaceOptionsBuilder) SetProjection ¶
func (f *FindOneAndReplaceOptionsBuilder) SetProjection(projection interface{}) *FindOneAndReplaceOptionsBuilder
SetProjection sets the value for the Projection field.
func (*FindOneAndReplaceOptionsBuilder) SetReturnDocument ¶
func (f *FindOneAndReplaceOptionsBuilder) SetReturnDocument(rd ReturnDocument) *FindOneAndReplaceOptionsBuilder
SetReturnDocument sets the value for the ReturnDocument field.
func (*FindOneAndReplaceOptionsBuilder) SetSort ¶
func (f *FindOneAndReplaceOptionsBuilder) SetSort(sort interface{}) *FindOneAndReplaceOptionsBuilder
SetSort sets the value for the Sort field.
func (*FindOneAndReplaceOptionsBuilder) SetUpsert ¶
func (f *FindOneAndReplaceOptionsBuilder) SetUpsert(b bool) *FindOneAndReplaceOptionsBuilder
SetUpsert sets the value for the Upsert field.
type FindOneAndUpdateOptions ¶
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. See https://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{} // 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{} }
FindOneAndUpdateOptions represents arguments that can be used to configure a FindOneAndUpdate options.
type FindOneAndUpdateOptionsBuilder ¶
type FindOneAndUpdateOptionsBuilder struct {
Opts []func(*FindOneAndUpdateOptions) error
}
FindOneAndUpdateOptionsBuilder contains options to configure a findOneAndUpdate operation. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func FindOneAndUpdate ¶
func FindOneAndUpdate() *FindOneAndUpdateOptionsBuilder
FindOneAndUpdate creates a new FindOneAndUpdateOptions instance.
func (*FindOneAndUpdateOptionsBuilder) List ¶
func (f *FindOneAndUpdateOptionsBuilder) List() []func(*FindOneAndUpdateOptions) error
List returns a list of FindOneAndUpdateOptions setter functions.
func (*FindOneAndUpdateOptionsBuilder) SetArrayFilters ¶
func (f *FindOneAndUpdateOptionsBuilder) SetArrayFilters(filters ArrayFilters) *FindOneAndUpdateOptionsBuilder
SetArrayFilters sets the value for the ArrayFilters field.
func (*FindOneAndUpdateOptionsBuilder) SetBypassDocumentValidation ¶
func (f *FindOneAndUpdateOptionsBuilder) SetBypassDocumentValidation(b bool) *FindOneAndUpdateOptionsBuilder
SetBypassDocumentValidation sets the value for the BypassDocumentValidation field.
func (*FindOneAndUpdateOptionsBuilder) SetCollation ¶
func (f *FindOneAndUpdateOptionsBuilder) SetCollation(collation *Collation) *FindOneAndUpdateOptionsBuilder
SetCollation sets the value for the Collation field.
func (*FindOneAndUpdateOptionsBuilder) SetComment ¶
func (f *FindOneAndUpdateOptionsBuilder) SetComment(comment interface{}) *FindOneAndUpdateOptionsBuilder
SetComment sets the value for the Comment field.
func (*FindOneAndUpdateOptionsBuilder) SetHint ¶
func (f *FindOneAndUpdateOptionsBuilder) SetHint(hint interface{}) *FindOneAndUpdateOptionsBuilder
SetHint sets the value for the Hint field.
func (*FindOneAndUpdateOptionsBuilder) SetLet ¶
func (f *FindOneAndUpdateOptionsBuilder) SetLet(let interface{}) *FindOneAndUpdateOptionsBuilder
SetLet sets the value for the Let field.
func (*FindOneAndUpdateOptionsBuilder) SetProjection ¶
func (f *FindOneAndUpdateOptionsBuilder) SetProjection(projection interface{}) *FindOneAndUpdateOptionsBuilder
SetProjection sets the value for the Projection field.
func (*FindOneAndUpdateOptionsBuilder) SetReturnDocument ¶
func (f *FindOneAndUpdateOptionsBuilder) SetReturnDocument(rd ReturnDocument) *FindOneAndUpdateOptionsBuilder
SetReturnDocument sets the value for the ReturnDocument field.
func (*FindOneAndUpdateOptionsBuilder) SetSort ¶
func (f *FindOneAndUpdateOptionsBuilder) SetSort(sort interface{}) *FindOneAndUpdateOptionsBuilder
SetSort sets the value for the Sort field.
func (*FindOneAndUpdateOptionsBuilder) SetUpsert ¶
func (f *FindOneAndUpdateOptionsBuilder) SetUpsert(b bool) *FindOneAndUpdateOptionsBuilder
SetUpsert sets the value for the Upsert field.
type FindOneOptions ¶
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 // 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 interface{} // The index to use for the aggregation. This should either be the index name as a string or the index specification // as a document. The 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{} // 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{} // 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 // 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 arguments that can be used to configure a FindOne operation.
type FindOneOptionsBuilder ¶
type FindOneOptionsBuilder struct {
Opts []func(*FindOneOptions) error
}
FindOneOptionsBuilder represents functional options that configure an FindOneopts.
func (*FindOneOptionsBuilder) List ¶
func (f *FindOneOptionsBuilder) List() []func(*FindOneOptions) error
List returns a list of FindOneOptions setter functions.
func (*FindOneOptionsBuilder) SetAllowPartialResults ¶
func (f *FindOneOptionsBuilder) SetAllowPartialResults(b bool) *FindOneOptionsBuilder
SetAllowPartialResults sets the value for the AllowPartialResults field.
func (*FindOneOptionsBuilder) SetCollation ¶
func (f *FindOneOptionsBuilder) SetCollation(collation *Collation) *FindOneOptionsBuilder
SetCollation sets the value for the Collation field.
func (*FindOneOptionsBuilder) SetComment ¶
func (f *FindOneOptionsBuilder) SetComment(comment interface{}) *FindOneOptionsBuilder
SetComment sets the value for the Comment field.
func (*FindOneOptionsBuilder) SetHint ¶
func (f *FindOneOptionsBuilder) SetHint(hint interface{}) *FindOneOptionsBuilder
SetHint sets the value for the Hint field.
func (*FindOneOptionsBuilder) SetMax ¶
func (f *FindOneOptionsBuilder) SetMax(max interface{}) *FindOneOptionsBuilder
SetMax sets the value for the Max field.
func (*FindOneOptionsBuilder) SetMin ¶
func (f *FindOneOptionsBuilder) SetMin(min interface{}) *FindOneOptionsBuilder
SetMin sets the value for the Min field.
func (*FindOneOptionsBuilder) SetProjection ¶
func (f *FindOneOptionsBuilder) SetProjection(projection interface{}) *FindOneOptionsBuilder
SetProjection sets the value for the Projection field.
func (*FindOneOptionsBuilder) SetReturnKey ¶
func (f *FindOneOptionsBuilder) SetReturnKey(b bool) *FindOneOptionsBuilder
SetReturnKey sets the value for the ReturnKey field.
func (*FindOneOptionsBuilder) SetShowRecordID ¶
func (f *FindOneOptionsBuilder) SetShowRecordID(b bool) *FindOneOptionsBuilder
SetShowRecordID sets the value for the ShowRecordID field.
func (*FindOneOptionsBuilder) SetSkip ¶
func (f *FindOneOptionsBuilder) SetSkip(i int64) *FindOneOptionsBuilder
SetSkip sets the value for the Skip field.
func (*FindOneOptionsBuilder) SetSort ¶
func (f *FindOneOptionsBuilder) SetSort(sort interface{}) *FindOneOptionsBuilder
SetSort sets the value for the Sort field.
type FindOptions ¶
type FindOptions struct { // 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 // 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 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{} // 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{} // 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 // 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{} // 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 // 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{} // 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 // BatchSize is the maximum number of documents to be included in each batch returned by the server. BatchSize *int32 // 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 // 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{} // 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 // NoCursorTimeout specifies whether the cursor created by the operation will not timeout after a period of inactivity. // The default value is false. NoCursorTimeout *bool }
FindOptions represents arguments that can be used to configure a Find operation.
type FindOptionsBuilder ¶
type FindOptionsBuilder struct {
Opts []func(*FindOptions) error
}
FindOptionsBuilder represents functional options that configure an Findopts.
func (*FindOptionsBuilder) List ¶
func (f *FindOptionsBuilder) List() []func(*FindOptions) error
List returns a list of FindOptions setter functions.
func (*FindOptionsBuilder) SetAllowDiskUse ¶
func (f *FindOptionsBuilder) SetAllowDiskUse(b bool) *FindOptionsBuilder
SetAllowDiskUse sets the value for the AllowDiskUse field.
func (*FindOptionsBuilder) SetAllowPartialResults ¶
func (f *FindOptionsBuilder) SetAllowPartialResults(b bool) *FindOptionsBuilder
SetAllowPartialResults sets the value for the AllowPartialResults field.
func (*FindOptionsBuilder) SetBatchSize ¶
func (f *FindOptionsBuilder) SetBatchSize(i int32) *FindOptionsBuilder
SetBatchSize sets the value for the BatchSize field.
func (*FindOptionsBuilder) SetCollation ¶
func (f *FindOptionsBuilder) SetCollation(collation *Collation) *FindOptionsBuilder
SetCollation sets the value for the Collation field.
func (*FindOptionsBuilder) SetComment ¶
func (f *FindOptionsBuilder) SetComment(comment interface{}) *FindOptionsBuilder
SetComment sets the value for the Comment field.
func (*FindOptionsBuilder) SetCursorType ¶
func (f *FindOptionsBuilder) SetCursorType(ct CursorType) *FindOptionsBuilder
SetCursorType sets the value for the CursorType field.
func (*FindOptionsBuilder) SetHint ¶
func (f *FindOptionsBuilder) SetHint(hint interface{}) *FindOptionsBuilder
SetHint sets the value for the Hint field.
func (*FindOptionsBuilder) SetLet ¶
func (f *FindOptionsBuilder) SetLet(let interface{}) *FindOptionsBuilder
SetLet sets the value for the Let field.
func (*FindOptionsBuilder) SetLimit ¶
func (f *FindOptionsBuilder) SetLimit(i int64) *FindOptionsBuilder
SetLimit sets the value for the Limit field.
func (*FindOptionsBuilder) SetMax ¶
func (f *FindOptionsBuilder) SetMax(max interface{}) *FindOptionsBuilder
SetMax sets the value for the Max field.
func (*FindOptionsBuilder) SetMaxAwaitTime ¶
func (f *FindOptionsBuilder) SetMaxAwaitTime(d time.Duration) *FindOptionsBuilder
SetMaxAwaitTime sets the value for the MaxAwaitTime field.
func (*FindOptionsBuilder) SetMin ¶
func (f *FindOptionsBuilder) SetMin(min interface{}) *FindOptionsBuilder
SetMin sets the value for the Min field.
func (*FindOptionsBuilder) SetNoCursorTimeout ¶
func (f *FindOptionsBuilder) SetNoCursorTimeout(b bool) *FindOptionsBuilder
SetNoCursorTimeout sets the value for the NoCursorTimeout field.
func (*FindOptionsBuilder) SetProjection ¶
func (f *FindOptionsBuilder) SetProjection(projection interface{}) *FindOptionsBuilder
SetProjection sets the value for the Projection field.
func (*FindOptionsBuilder) SetReturnKey ¶
func (f *FindOptionsBuilder) SetReturnKey(b bool) *FindOptionsBuilder
SetReturnKey sets the value for the ReturnKey field.
func (*FindOptionsBuilder) SetShowRecordID ¶
func (f *FindOptionsBuilder) SetShowRecordID(b bool) *FindOptionsBuilder
SetShowRecordID sets the value for the ShowRecordID field.
func (*FindOptionsBuilder) SetSkip ¶
func (f *FindOptionsBuilder) SetSkip(i int64) *FindOptionsBuilder
SetSkip sets the value for the Skip field.
func (*FindOptionsBuilder) SetSort ¶
func (f *FindOptionsBuilder) SetSort(sort interface{}) *FindOptionsBuilder
SetSort sets the value for the Sort field.
type FullDocument ¶
type FullDocument string
FullDocument specifies how a change stream should return the modified document.
const ( // Default does not include a document copy. Default FullDocument = "default" // Off is the same as sending no value for fullDocumentBeforeChange. Off FullDocument = "off" // Required is the same as WhenAvailable but raises a server-side error if the post-image is not available. Required FullDocument = "required" // UpdateLookup includes a delta describing the changes to the document and a copy of the entire document that // was changed. UpdateLookup FullDocument = "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. WhenAvailable FullDocument = "whenAvailable" )
type GridFSFindOptions ¶
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 // 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 arguments that can be used to configure a GridFS Find operation.
type GridFSFindOptionsBuilder ¶
type GridFSFindOptionsBuilder struct {
Opts []func(*GridFSFindOptions) error
}
GridFSFindOptionsBuilder contains options to configure find operations. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func GridFSFind ¶
func GridFSFind() *GridFSFindOptionsBuilder
GridFSFind creates a new GridFSFindOptions instance.
func (*GridFSFindOptionsBuilder) List ¶
func (f *GridFSFindOptionsBuilder) List() []func(*GridFSFindOptions) error
List returns a list of GridFSFindOptions setter functions.
func (*GridFSFindOptionsBuilder) SetAllowDiskUse ¶
func (f *GridFSFindOptionsBuilder) SetAllowDiskUse(b bool) *GridFSFindOptionsBuilder
SetAllowDiskUse sets the value for the AllowDiskUse field.
func (*GridFSFindOptionsBuilder) SetBatchSize ¶
func (f *GridFSFindOptionsBuilder) SetBatchSize(i int32) *GridFSFindOptionsBuilder
SetBatchSize sets the value for the BatchSize field.
func (*GridFSFindOptionsBuilder) SetLimit ¶
func (f *GridFSFindOptionsBuilder) SetLimit(i int32) *GridFSFindOptionsBuilder
SetLimit sets the value for the Limit field.
func (*GridFSFindOptionsBuilder) SetNoCursorTimeout ¶
func (f *GridFSFindOptionsBuilder) SetNoCursorTimeout(b bool) *GridFSFindOptionsBuilder
SetNoCursorTimeout sets the value for the NoCursorTimeout field.
func (*GridFSFindOptionsBuilder) SetSkip ¶
func (f *GridFSFindOptionsBuilder) SetSkip(i int32) *GridFSFindOptionsBuilder
SetSkip sets the value for the Skip field.
func (*GridFSFindOptionsBuilder) SetSort ¶
func (f *GridFSFindOptionsBuilder) SetSort(sort interface{}) *GridFSFindOptionsBuilder
SetSort sets the value for the Sort field.
type GridFSNameOptions ¶
type GridFSNameOptions 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 -1 Revision *int32 }
GridFSNameOptions represents arguments that can be used to configure a GridFS DownloadByName operation.
type GridFSNameOptionsBuilder ¶
type GridFSNameOptionsBuilder struct {
Opts []func(*GridFSNameOptions) error
}
GridFSNameOptionsBuilder contains options to configure a GridFS name. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func GridFSName ¶
func GridFSName() *GridFSNameOptionsBuilder
GridFSName creates a new GridFSNameOptions instance.
func (*GridFSNameOptionsBuilder) List ¶
func (n *GridFSNameOptionsBuilder) List() []func(*GridFSNameOptions) error
List returns a list of GridFSNameOptions setter functions.
func (*GridFSNameOptionsBuilder) SetRevision ¶
func (n *GridFSNameOptionsBuilder) SetRevision(r int32) *GridFSNameOptionsBuilder
SetRevision sets the value for the Revision field.
type GridFSUploadOptions ¶
type GridFSUploadOptions 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 *bson.Registry }
GridFSUploadOptions represents arguments that can be used to configure a GridFS upload operation.
type GridFSUploadOptionsBuilder ¶
type GridFSUploadOptionsBuilder struct {
Opts []func(*GridFSUploadOptions) error
}
GridFSUploadOptionsBuilder contains options to configure a GridFS Upload. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func GridFSUpload ¶
func GridFSUpload() *GridFSUploadOptionsBuilder
GridFSUpload creates a new GridFSUploadOptions instance.
func (*GridFSUploadOptionsBuilder) List ¶
func (u *GridFSUploadOptionsBuilder) List() []func(*GridFSUploadOptions) error
List returns a list of GridFSUploadOptions setter functions.
func (*GridFSUploadOptionsBuilder) SetChunkSizeBytes ¶
func (u *GridFSUploadOptionsBuilder) SetChunkSizeBytes(i int32) *GridFSUploadOptionsBuilder
SetChunkSizeBytes sets the value for the ChunkSize field.
func (*GridFSUploadOptionsBuilder) SetMetadata ¶
func (u *GridFSUploadOptionsBuilder) SetMetadata(doc interface{}) *GridFSUploadOptionsBuilder
SetMetadata sets the value for the Metadata field.
func (*GridFSUploadOptionsBuilder) SetRegistry ¶
func (u *GridFSUploadOptionsBuilder) SetRegistry(registry *bson.Registry) *GridFSUploadOptionsBuilder
SetRegistry sets the bson codec registry for the Registry field.
type IndexOptions ¶
type IndexOptions struct { // 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. See https://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. See https://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 arguments that can be used to configure a new index created through the IndexView.CreateOne or IndexView.CreateMany operations.
type IndexOptionsBuilder ¶
type IndexOptionsBuilder struct {
Opts []func(*IndexOptions) error
}
IndexOptionsBuilder contains options to configure index operations. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func (*IndexOptionsBuilder) List ¶
func (i *IndexOptionsBuilder) List() []func(*IndexOptions) error
List returns a list of IndexOptions setter functions.
func (*IndexOptionsBuilder) SetBits ¶
func (i *IndexOptionsBuilder) SetBits(bits int32) *IndexOptionsBuilder
SetBits sets the value for the Bits field.
func (*IndexOptionsBuilder) SetBucketSize ¶
func (i *IndexOptionsBuilder) SetBucketSize(bucketSize int32) *IndexOptionsBuilder
SetBucketSize sets the value for the BucketSize field
func (*IndexOptionsBuilder) SetCollation ¶
func (i *IndexOptionsBuilder) SetCollation(collation *Collation) *IndexOptionsBuilder
SetCollation sets the value for the Collation field.
func (*IndexOptionsBuilder) SetDefaultLanguage ¶
func (i *IndexOptionsBuilder) SetDefaultLanguage(language string) *IndexOptionsBuilder
SetDefaultLanguage sets the value for the DefaultLanguage field.
func (*IndexOptionsBuilder) SetExpireAfterSeconds ¶
func (i *IndexOptionsBuilder) SetExpireAfterSeconds(seconds int32) *IndexOptionsBuilder
SetExpireAfterSeconds sets value for the ExpireAfterSeconds field.
func (*IndexOptionsBuilder) SetHidden ¶
func (i *IndexOptionsBuilder) SetHidden(hidden bool) *IndexOptionsBuilder
SetHidden sets the value for the Hidden field.
func (*IndexOptionsBuilder) SetLanguageOverride ¶
func (i *IndexOptionsBuilder) SetLanguageOverride(override string) *IndexOptionsBuilder
SetLanguageOverride sets the value of the LanguageOverride field.
func (*IndexOptionsBuilder) SetMax ¶
func (i *IndexOptionsBuilder) SetMax(max float64) *IndexOptionsBuilder
SetMax sets the value for the Max field.
func (*IndexOptionsBuilder) SetMin ¶
func (i *IndexOptionsBuilder) SetMin(min float64) *IndexOptionsBuilder
SetMin sets the value for the Min field.
func (*IndexOptionsBuilder) SetName ¶
func (i *IndexOptionsBuilder) SetName(name string) *IndexOptionsBuilder
SetName sets the value for the Name field.
func (*IndexOptionsBuilder) SetPartialFilterExpression ¶
func (i *IndexOptionsBuilder) SetPartialFilterExpression(expression interface{}) *IndexOptionsBuilder
SetPartialFilterExpression sets the value for the PartialFilterExpression field.
func (*IndexOptionsBuilder) SetSparse ¶
func (i *IndexOptionsBuilder) SetSparse(sparse bool) *IndexOptionsBuilder
SetSparse sets the value of the Sparse field.
func (*IndexOptionsBuilder) SetSphereVersion ¶
func (i *IndexOptionsBuilder) SetSphereVersion(version int32) *IndexOptionsBuilder
SetSphereVersion sets the value for the SphereVersion field.
func (*IndexOptionsBuilder) SetStorageEngine ¶
func (i *IndexOptionsBuilder) SetStorageEngine(engine interface{}) *IndexOptionsBuilder
SetStorageEngine sets the value for the StorageEngine field.
func (*IndexOptionsBuilder) SetTextVersion ¶
func (i *IndexOptionsBuilder) SetTextVersion(version int32) *IndexOptionsBuilder
SetTextVersion sets the value for the TextVersion field.
func (*IndexOptionsBuilder) SetUnique ¶
func (i *IndexOptionsBuilder) SetUnique(unique bool) *IndexOptionsBuilder
SetUnique sets the value for the Unique field.
func (*IndexOptionsBuilder) SetVersion ¶
func (i *IndexOptionsBuilder) SetVersion(version int32) *IndexOptionsBuilder
SetVersion sets the value for the Version field.
func (*IndexOptionsBuilder) SetWeights ¶
func (i *IndexOptionsBuilder) SetWeights(weights interface{}) *IndexOptionsBuilder
SetWeights sets the value for the Weights field.
func (*IndexOptionsBuilder) SetWildcardProjection ¶
func (i *IndexOptionsBuilder) SetWildcardProjection(wildcardProjection interface{}) *IndexOptionsBuilder
SetWildcardProjection sets the value for the WildcardProjection field.
type InsertManyOptions ¶
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. See https://www.mongodb.com/docs/manual/core/schema-validation/ for more information about document // validation. BypassDocumentValidation *bool // A string or document that will be included in server logs, profiling logs, and currentOp queries to help trace // the operation. The default value is nil, which means that no comment will be included in the logs. Comment interface{} // If true, no writes will be executed after one fails. The default value is true. Ordered *bool }
InsertManyOptions represents arguments that can be used to configure an InsertMany operation.
type InsertManyOptionsBuilder ¶
type InsertManyOptionsBuilder struct {
Opts []func(*InsertManyOptions) error
}
InsertManyOptionsBuilder contains options to configure insert operations. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func InsertMany ¶
func InsertMany() *InsertManyOptionsBuilder
InsertMany creates a new InsertManyOptions instance.
func (*InsertManyOptionsBuilder) List ¶
func (imo *InsertManyOptionsBuilder) List() []func(*InsertManyOptions) error
List returns a list of InsertManyOptions setter functions.
func (*InsertManyOptionsBuilder) SetBypassDocumentValidation ¶
func (imo *InsertManyOptionsBuilder) SetBypassDocumentValidation(b bool) *InsertManyOptionsBuilder
SetBypassDocumentValidation sets the value for the BypassDocumentValidation field.
func (*InsertManyOptionsBuilder) SetComment ¶
func (imo *InsertManyOptionsBuilder) SetComment(comment interface{}) *InsertManyOptionsBuilder
SetComment sets the value for the Comment field.
func (*InsertManyOptionsBuilder) SetOrdered ¶
func (imo *InsertManyOptionsBuilder) SetOrdered(b bool) *InsertManyOptionsBuilder
SetOrdered sets the value for the Ordered field.
type InsertOneOptions ¶
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. See https://www.mongodb.com/docs/manual/core/schema-validation/ for more information about document // validation. BypassDocumentValidation *bool // A string or document that will be included in server logs, profiling logs, and currentOp queries to help trace // the operation. The default value is nil, which means that no comment will be included in the logs. Comment interface{} }
InsertOneOptions represents arguments that can be used to configure an InsertOne operation.
type InsertOneOptionsBuilder ¶
type InsertOneOptionsBuilder struct {
Opts []func(*InsertOneOptions) error
}
InsertOneOptionsBuilder represents functional options that configure an InsertOneopts.
func InsertOne ¶
func InsertOne() *InsertOneOptionsBuilder
InsertOne creates a new InsertOneOptions instance.
func (*InsertOneOptionsBuilder) List ¶
func (ioo *InsertOneOptionsBuilder) List() []func(*InsertOneOptions) error
List returns a list of InsertOneOptions setter functions.
func (*InsertOneOptionsBuilder) SetBypassDocumentValidation ¶
func (ioo *InsertOneOptionsBuilder) SetBypassDocumentValidation(b bool) *InsertOneOptionsBuilder
SetBypassDocumentValidation sets the value for the BypassDocumentValidation field.
func (*InsertOneOptionsBuilder) SetComment ¶
func (ioo *InsertOneOptionsBuilder) SetComment(comment interface{}) *InsertOneOptionsBuilder
SetComment sets the value for the Comment field.
type ListCollectionsOptions ¶
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 arguments that can be used to configure a ListCollections operation.
type ListCollectionsOptionsBuilder ¶
type ListCollectionsOptionsBuilder struct {
Opts []func(*ListCollectionsOptions) error
}
ListCollectionsOptionsBuilder contains options to configure list collection operations. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func ListCollections ¶
func ListCollections() *ListCollectionsOptionsBuilder
ListCollections creates a new ListCollectionsOptions instance.
func (*ListCollectionsOptionsBuilder) List ¶
func (lc *ListCollectionsOptionsBuilder) List() []func(*ListCollectionsOptions) error
List returns a list of CountOptions setter functions.
func (*ListCollectionsOptionsBuilder) SetAuthorizedCollections ¶
func (lc *ListCollectionsOptionsBuilder) SetAuthorizedCollections(b bool) *ListCollectionsOptionsBuilder
SetAuthorizedCollections sets the value for the AuthorizedCollections field. This option is only valid for MongoDB server versions >= 4.0. Server versions < 4.0 ignore this option.
func (*ListCollectionsOptionsBuilder) SetBatchSize ¶
func (lc *ListCollectionsOptionsBuilder) SetBatchSize(size int32) *ListCollectionsOptionsBuilder
SetBatchSize sets the value for the BatchSize field.
func (*ListCollectionsOptionsBuilder) SetNameOnly ¶
func (lc *ListCollectionsOptionsBuilder) SetNameOnly(b bool) *ListCollectionsOptionsBuilder
SetNameOnly sets the value for the NameOnly field.
type ListDatabasesOptions ¶
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, see https://www.mongodb.com/docs/manual/reference/privilege-actions/#find. The default // value is true. AuthorizedDatabases *bool }
ListDatabasesOptions represents arguments that can be used to configure a ListDatabases operation.
type ListDatabasesOptionsBuilder ¶
type ListDatabasesOptionsBuilder struct {
Opts []func(*ListDatabasesOptions) error
}
ListDatabasesOptionsBuilder represents functional options that configure a ListDatabasesopts.
func ListDatabases ¶
func ListDatabases() *ListDatabasesOptionsBuilder
ListDatabases creates a new ListDatabasesOptions instance.
func (*ListDatabasesOptionsBuilder) List ¶
func (ld *ListDatabasesOptionsBuilder) List() []func(*ListDatabasesOptions) error
List returns a list of ListDatabasesOptions setter functions.
func (*ListDatabasesOptionsBuilder) SetAuthorizedDatabases ¶
func (ld *ListDatabasesOptionsBuilder) SetAuthorizedDatabases(b bool) *ListDatabasesOptionsBuilder
SetAuthorizedDatabases sets the value for the AuthorizedDatabases field.
func (*ListDatabasesOptionsBuilder) SetNameOnly ¶
func (ld *ListDatabasesOptionsBuilder) SetNameOnly(b bool) *ListDatabasesOptionsBuilder
SetNameOnly sets the value for the NameOnly field.
type ListIndexesOptions ¶
type ListIndexesOptions struct { // The maximum number of documents to be included in each batch returned by the server. BatchSize *int32 }
ListIndexesOptions represents arguments that can be used to configure an IndexView.List operation.
type ListIndexesOptionsBuilder ¶
type ListIndexesOptionsBuilder struct {
Opts []func(*ListIndexesOptions) error
}
ListIndexesOptionsBuilder contains options to configure count operations. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func ListIndexes ¶
func ListIndexes() *ListIndexesOptionsBuilder
ListIndexes creates a new ListIndexesOptions instance.
func (*ListIndexesOptionsBuilder) List ¶
func (l *ListIndexesOptionsBuilder) List() []func(*ListIndexesOptions) error
List returns a list of CountOptions setter functions.
func (*ListIndexesOptionsBuilder) SetBatchSize ¶
func (l *ListIndexesOptionsBuilder) SetBatchSize(i int32) *ListIndexesOptionsBuilder
SetBatchSize sets the value for the BatchSize field.
type ListSearchIndexesOptions ¶
type ListSearchIndexesOptions struct {
AggregateOptions *AggregateOptions
}
ListSearchIndexesOptions represents arguments that can be used to configure a SearchIndexView.List operation.
type ListSearchIndexesOptionsBuilder ¶
type ListSearchIndexesOptionsBuilder struct {
Opts []func(*ListSearchIndexesOptions) error
}
ListSearchIndexesOptionsBuilder contains options that can be used to configure a SearchIndexView.List operation.
func (*ListSearchIndexesOptionsBuilder) List ¶
func (lsi *ListSearchIndexesOptionsBuilder) List() []func(*ListSearchIndexesOptions) error
List returns a list of ListSearchIndexesOptions setter functions.
type LogComponent ¶
type LogComponent int
LogComponent is an enumeration representing the "components" which can be logged against. A LogLevel can be configured on a per-component basis.
const ( // LogComponentAll enables logging for all components. LogComponentAll LogComponent = LogComponent(logger.ComponentAll) // LogComponentCommand enables command monitor logging. LogComponentCommand LogComponent = LogComponent(logger.ComponentCommand) // LogComponentTopology enables topology logging. LogComponentTopology LogComponent = LogComponent(logger.ComponentTopology) // LogComponentServerSelection enables server selection logging. LogComponentServerSelection LogComponent = LogComponent(logger.ComponentServerSelection) // LogComponentConnection enables connection services logging. LogComponentConnection LogComponent = LogComponent(logger.ComponentConnection) )
type LogLevel ¶
type LogLevel int
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. LogLevelInfo LogLevel = 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. LogLevelDebug LogLevel = LogLevel(logger.LevelDebug) )
type LogSink ¶
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(level int, message string, keysAndValues ...interface{}) // Error logs an error message with the given key/value pairs Error(err error, message string, keysAndValues ...interface{}) }
LogSink is an interface that can be implemented to provide a custom sink for the driver's logs.
type LoggerOptions ¶
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. Sink LogSink // 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 "...". MaxDocumentLength uint }
LoggerOptions represent arguments used to configure Logging in the Go Driver.
type LoggerOptionsBuilder ¶
type LoggerOptionsBuilder struct {
Opts []func(*LoggerOptions) error
}
LoggerOptionsBuilder contains options to configure a logger. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func (*LoggerOptionsBuilder) List ¶
func (opts *LoggerOptionsBuilder) List() []func(*LoggerOptions) error
List returns a list of LoggerOptions setter functions.
func (*LoggerOptionsBuilder) SetComponentLevel ¶
func (opts *LoggerOptionsBuilder) SetComponentLevel(component LogComponent, level LogLevel) *LoggerOptionsBuilder
SetComponentLevel sets the LogLevel value for a LogComponent.
func (*LoggerOptionsBuilder) SetMaxDocumentLength ¶
func (opts *LoggerOptionsBuilder) SetMaxDocumentLength(maxDocumentLength uint) *LoggerOptionsBuilder
SetMaxDocumentLength sets the maximum length of a document to be logged.
func (*LoggerOptionsBuilder) SetSink ¶
func (opts *LoggerOptionsBuilder) SetSink(sink LogSink) *LoggerOptionsBuilder
SetSink sets the LogSink to use for logging.
type RangeOptions ¶
RangeOptions specifies index options for a Queryable Encryption field supporting "rangePreview" queries. Beta: The Range algorithm is experimental only. It is not intended for public use. It is subject to breaking changes.
type RangeOptionsBuilder ¶
type RangeOptionsBuilder struct {
Opts []func(*RangeOptions) error
}
RangeOptionsBuilder contains options to configure Rangeopts for queryeable encryption. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func (*RangeOptionsBuilder) List ¶
func (ro *RangeOptionsBuilder) List() []func(*RangeOptions) error
List returns a list of RangeOptions setter functions.
func (*RangeOptionsBuilder) SetMax ¶
func (ro *RangeOptionsBuilder) SetMax(max bson.RawValue) *RangeOptionsBuilder
SetMax sets the range index maximum value. Beta: The Range algorithm is experimental only. It is not intended for public use. It is subject to breaking changes.
func (*RangeOptionsBuilder) SetMin ¶
func (ro *RangeOptionsBuilder) SetMin(min bson.RawValue) *RangeOptionsBuilder
SetMin sets the range index minimum value. Beta: The Range algorithm is experimental only. It is not intended for public use. It is subject to breaking changes.
func (*RangeOptionsBuilder) SetPrecision ¶
func (ro *RangeOptionsBuilder) SetPrecision(precision int32) *RangeOptionsBuilder
SetPrecision sets the range index precision. Beta: The Range algorithm is experimental only. It is not intended for public use. It is subject to breaking changes.
func (*RangeOptionsBuilder) SetSparsity ¶
func (ro *RangeOptionsBuilder) SetSparsity(sparsity int64) *RangeOptionsBuilder
SetSparsity sets the range index sparsity. Beta: The Range algorithm is experimental only. It is not intended for public use. It is subject to breaking changes.
type ReplaceOptions ¶
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. See https://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{} }
ReplaceOptions represents arguments that can be used to configure a ReplaceOne operation.
type ReplaceOptionsBuilder ¶
type ReplaceOptionsBuilder struct {
Opts []func(*ReplaceOptions) error
}
ReplaceOptionsBuilder contains options to configure replace operations. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func (*ReplaceOptionsBuilder) List ¶
func (ro *ReplaceOptionsBuilder) List() []func(*ReplaceOptions) error
List returns a list of CountOptions setter functions.
func (*ReplaceOptionsBuilder) SetBypassDocumentValidation ¶
func (ro *ReplaceOptionsBuilder) SetBypassDocumentValidation(b bool) *ReplaceOptionsBuilder
SetBypassDocumentValidation sets the value for the BypassDocumentValidation field.
func (*ReplaceOptionsBuilder) SetCollation ¶
func (ro *ReplaceOptionsBuilder) SetCollation(c *Collation) *ReplaceOptionsBuilder
SetCollation sets the value for the Collation field.
func (*ReplaceOptionsBuilder) SetComment ¶
func (ro *ReplaceOptionsBuilder) SetComment(comment interface{}) *ReplaceOptionsBuilder
SetComment sets the value for the Comment field.
func (*ReplaceOptionsBuilder) SetHint ¶
func (ro *ReplaceOptionsBuilder) SetHint(h interface{}) *ReplaceOptionsBuilder
SetHint sets the value for the Hint field.
func (*ReplaceOptionsBuilder) SetLet ¶
func (ro *ReplaceOptionsBuilder) SetLet(l interface{}) *ReplaceOptionsBuilder
SetLet sets the value for the Let field.
func (*ReplaceOptionsBuilder) SetUpsert ¶
func (ro *ReplaceOptionsBuilder) SetUpsert(b bool) *ReplaceOptionsBuilder
SetUpsert sets the value for the Upsert field.
type ReturnDocument ¶
type ReturnDocument int8
ReturnDocument specifies whether a findAndUpdate operation should return the document as it was before the update or as it is after the update.
const ( // Before specifies that findAndUpdate should return the document as it was before the update. Before ReturnDocument = iota // After specifies that findAndUpdate should return the document as it is after the update. After )
type RewrapManyDataKeyOptions ¶
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 a possibly new masterKey.
type RewrapManyDataKeyOptionsBuilder ¶
type RewrapManyDataKeyOptionsBuilder struct {
Opts []func(*RewrapManyDataKeyOptions) error
}
RewrapManyDataKeyOptionsBuilder contains options to configure rewraping a data key. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func RewrapManyDataKey ¶
func RewrapManyDataKey() *RewrapManyDataKeyOptionsBuilder
RewrapManyDataKey creates a new RewrapManyDataKeyOptions instance.
func (*RewrapManyDataKeyOptionsBuilder) List ¶
func (rmdko *RewrapManyDataKeyOptionsBuilder) List() []func(*RewrapManyDataKeyOptions) error
List returns a list of CountOptions setter functions.
func (*RewrapManyDataKeyOptionsBuilder) SetMasterKey ¶
func (rmdko *RewrapManyDataKeyOptionsBuilder) SetMasterKey(masterKey interface{}) *RewrapManyDataKeyOptionsBuilder
SetMasterKey sets the value for the MasterKey field.
func (*RewrapManyDataKeyOptionsBuilder) SetProvider ¶
func (rmdko *RewrapManyDataKeyOptionsBuilder) SetProvider(provider string) *RewrapManyDataKeyOptionsBuilder
SetProvider sets the value for the Provider field.
type RunCmdOptions ¶
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 arguments that can be used to configure a RunCommand operation.
type RunCmdOptionsBuilder ¶
type RunCmdOptionsBuilder struct {
Opts []func(*RunCmdOptions) error
}
RunCmdOptionsBuilder contains options to configure runCommand operations. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func (*RunCmdOptionsBuilder) List ¶
func (rc *RunCmdOptionsBuilder) List() []func(*RunCmdOptions) error
List returns a list of CountOptions setter functions.
func (*RunCmdOptionsBuilder) SetReadPreference ¶
func (rc *RunCmdOptionsBuilder) SetReadPreference(rp *readpref.ReadPref) *RunCmdOptionsBuilder
SetReadPreference sets value for the ReadPreference field.
type SearchIndexesOptions ¶
SearchIndexesOptions represents arguments that can be used to configure a SearchIndexView.
type SearchIndexesOptionsBuilder ¶
type SearchIndexesOptionsBuilder struct {
Opts []func(*SearchIndexesOptions) error
}
SearchIndexesOptionsBuilder contains options to configure search index operations. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func SearchIndexes ¶
func SearchIndexes() *SearchIndexesOptionsBuilder
SearchIndexes creates a new SearchIndexesOptions instance.
func (*SearchIndexesOptionsBuilder) List ¶
func (sio *SearchIndexesOptionsBuilder) List() []func(*SearchIndexesOptions) error
List returns a list of CountOptions setter functions.
func (*SearchIndexesOptionsBuilder) SetName ¶
func (sio *SearchIndexesOptionsBuilder) SetName(name string) *SearchIndexesOptionsBuilder
SetName sets the value for the Name field.
func (*SearchIndexesOptionsBuilder) SetType ¶
func (sio *SearchIndexesOptionsBuilder) SetType(typ string) *SearchIndexesOptionsBuilder
SetType sets the value for the Type field.
type ServerAPIOptions ¶
type ServerAPIOptions struct { ServerAPIVersion ServerAPIVersion Strict *bool DeprecationErrors *bool }
ServerAPIOptions represents arguments used to configure the API version sent to the server when running commands.
Sending a specified server API version causes the server to behave in a manner compatible with that API version. It also causes the driver to behave in a manner compatible with the driver’s behavior as of 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 version must also be currently supported by the driver. This version of the driver supports API version "1".
type ServerAPIOptionsBuilder ¶
type ServerAPIOptionsBuilder struct {
Opts []func(*ServerAPIOptions) error
}
ServerAPIOptionsBuilder contains options to configure serverAPI operations. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func ServerAPI ¶
func ServerAPI(serverAPIVersion ServerAPIVersion) *ServerAPIOptionsBuilder
ServerAPI creates a new ServerAPIOptions configured with the provided serverAPIversion.
func (*ServerAPIOptionsBuilder) List ¶
func (s *ServerAPIOptionsBuilder) List() []func(*ServerAPIOptions) error
List returns a list of ServerAPIOptions setter functions.
func (*ServerAPIOptionsBuilder) SetDeprecationErrors ¶
func (s *ServerAPIOptionsBuilder) SetDeprecationErrors(deprecationErrors bool) *ServerAPIOptionsBuilder
SetDeprecationErrors specifies whether the server should return errors for deprecated features.
func (*ServerAPIOptionsBuilder) SetStrict ¶
func (s *ServerAPIOptionsBuilder) SetStrict(strict bool) *ServerAPIOptionsBuilder
SetStrict specifies whether the server should return errors for features that are not part of the API version.
type ServerAPIVersion ¶
type ServerAPIVersion string
ServerAPIVersion represents an API version that can be used in ServerAPIOptions.
const ( // ServerAPIVersion1 is the first API version. ServerAPIVersion1 ServerAPIVersion = "1" )
func (ServerAPIVersion) Validate ¶
func (sav ServerAPIVersion) Validate() error
Validate determines if the provided ServerAPIVersion is currently supported by the driver.
type SessionOptions ¶
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 options for transactions started in the session. If this object // or any value on the object is nil, the client-level read concern, // write concern, and/or read preference will be used to start the session. DefaultTransactionOptions *TransactionOptionsBuilder // 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 arguments that can be used to configure a Session.
type SessionOptionsBuilder ¶
type SessionOptionsBuilder struct {
Opts []func(*SessionOptions) error
}
SessionOptionsBuilder represents functional options that configure a Sessionopts.
func (*SessionOptionsBuilder) List ¶
func (s *SessionOptionsBuilder) List() []func(*SessionOptions) error
List returns a list of SessionOptions setter functions.
func (*SessionOptionsBuilder) SetCausalConsistency ¶
func (s *SessionOptionsBuilder) SetCausalConsistency(b bool) *SessionOptionsBuilder
SetCausalConsistency sets the value for the CausalConsistency field.
func (*SessionOptionsBuilder) SetDefaultTransactionOptions ¶
func (s *SessionOptionsBuilder) SetDefaultTransactionOptions(dt *TransactionOptionsBuilder) *SessionOptionsBuilder
SetDefaultTransactionOptions sets the value for the DefaultTransactionOptions field.
func (*SessionOptionsBuilder) SetSnapshot ¶
func (s *SessionOptionsBuilder) SetSnapshot(b bool) *SessionOptionsBuilder
SetSnapshot sets the value for the Snapshot field.
type TimeSeriesOptions ¶
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). TimeField string // 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 arguments on a time-series collection.
type TimeSeriesOptionsBuilder ¶
type TimeSeriesOptionsBuilder struct {
Opts []func(*TimeSeriesOptions) error
}
TimeSeriesOptionsBuilder contains options to configure timeseries operations. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func TimeSeries ¶
func TimeSeries() *TimeSeriesOptionsBuilder
TimeSeries creates a new TimeSeriesOptions instance.
func (*TimeSeriesOptionsBuilder) List ¶
func (tso *TimeSeriesOptionsBuilder) List() []func(*TimeSeriesOptions) error
List returns a list of TimeSeriesOptions setter functions.
func (*TimeSeriesOptionsBuilder) SetBucketMaxSpan ¶
func (tso *TimeSeriesOptionsBuilder) SetBucketMaxSpan(dur time.Duration) *TimeSeriesOptionsBuilder
SetBucketMaxSpan sets the value for BucketMaxSpan.
func (*TimeSeriesOptionsBuilder) SetBucketRounding ¶
func (tso *TimeSeriesOptionsBuilder) SetBucketRounding(dur time.Duration) *TimeSeriesOptionsBuilder
SetBucketRounding sets the value for BucketRounding.
func (*TimeSeriesOptionsBuilder) SetGranularity ¶
func (tso *TimeSeriesOptionsBuilder) SetGranularity(granularity string) *TimeSeriesOptionsBuilder
SetGranularity sets the value for Granularity.
func (*TimeSeriesOptionsBuilder) SetMetaField ¶
func (tso *TimeSeriesOptionsBuilder) SetMetaField(metaField string) *TimeSeriesOptionsBuilder
SetMetaField sets the value for the MetaField.
func (*TimeSeriesOptionsBuilder) SetTimeField ¶
func (tso *TimeSeriesOptionsBuilder) SetTimeField(timeField string) *TimeSeriesOptionsBuilder
SetTimeField sets the value for the TimeField.
type TransactionOptions ¶
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 }
TransactionOptions represents arguments that can be used to configure a transaction.
type TransactionOptionsBuilder ¶
type TransactionOptionsBuilder struct {
Opts []func(*TransactionOptions) error
}
TransactionOptionsBuilder contains arguments to configure count operations. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func Transaction ¶
func Transaction() *TransactionOptionsBuilder
Transaction creates a new TransactionOptions instance.
func (*TransactionOptionsBuilder) List ¶
func (t *TransactionOptionsBuilder) List() []func(*TransactionOptions) error
List returns a list of TransactionOptions setter functions.
func (*TransactionOptionsBuilder) SetReadConcern ¶
func (t *TransactionOptionsBuilder) SetReadConcern(rc *readconcern.ReadConcern) *TransactionOptionsBuilder
SetReadConcern sets the value for the ReadConcern field.
func (*TransactionOptionsBuilder) SetReadPreference ¶
func (t *TransactionOptionsBuilder) SetReadPreference(rp *readpref.ReadPref) *TransactionOptionsBuilder
SetReadPreference sets the value for the ReadPreference field.
func (*TransactionOptionsBuilder) SetWriteConcern ¶
func (t *TransactionOptionsBuilder) SetWriteConcern(wc *writeconcern.WriteConcern) *TransactionOptionsBuilder
SetWriteConcern sets the value for the WriteConcern field.
type UpdateOptions ¶
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. See https://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{} }
UpdateOptions represents arguments that can be used to configure UpdateOne and UpdateMany operations.
type UpdateOptionsBuilder ¶
type UpdateOptionsBuilder struct {
Opts []func(*UpdateOptions) error
}
UpdateOptionsBuilder contains options to configure update operations. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func (*UpdateOptionsBuilder) List ¶
func (uo *UpdateOptionsBuilder) List() []func(*UpdateOptions) error
List returns a list of UpdateOptions setter functions.
func (*UpdateOptionsBuilder) SetArrayFilters ¶
func (uo *UpdateOptionsBuilder) SetArrayFilters(af ArrayFilters) *UpdateOptionsBuilder
SetArrayFilters sets the value for the ArrayFilters field.
func (*UpdateOptionsBuilder) SetBypassDocumentValidation ¶
func (uo *UpdateOptionsBuilder) SetBypassDocumentValidation(b bool) *UpdateOptionsBuilder
SetBypassDocumentValidation sets the value for the BypassDocumentValidation field.
func (*UpdateOptionsBuilder) SetCollation ¶
func (uo *UpdateOptionsBuilder) SetCollation(c *Collation) *UpdateOptionsBuilder
SetCollation sets the value for the Collation field.
func (*UpdateOptionsBuilder) SetComment ¶
func (uo *UpdateOptionsBuilder) SetComment(comment interface{}) *UpdateOptionsBuilder
SetComment sets the value for the Comment field.
func (*UpdateOptionsBuilder) SetHint ¶
func (uo *UpdateOptionsBuilder) SetHint(h interface{}) *UpdateOptionsBuilder
SetHint sets the value for the Hint field.
func (*UpdateOptionsBuilder) SetLet ¶
func (uo *UpdateOptionsBuilder) SetLet(l interface{}) *UpdateOptionsBuilder
SetLet sets the value for the Let field.
func (*UpdateOptionsBuilder) SetUpsert ¶
func (uo *UpdateOptionsBuilder) SetUpsert(b bool) *UpdateOptionsBuilder
SetUpsert sets the value for the Upsert field.
type UpdateSearchIndexOptions ¶
type UpdateSearchIndexOptions struct{}
UpdateSearchIndexOptions represents arguments that can be used to configure a SearchIndexView.UpdateOne operation.
type UpdateSearchIndexOptionsBuilder ¶
type UpdateSearchIndexOptionsBuilder struct {
Opts []func(*UpdateSearchIndexOptions) error
}
UpdateSearchIndexOptionsBuilder contains options to configure updating search indexes. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func (*UpdateSearchIndexOptionsBuilder) List ¶
func (usio *UpdateSearchIndexOptionsBuilder) List() []func(*UpdateSearchIndexOptions) error
List returns a list of UpdateSearchIndexOptions setter functions.
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
- dropcollectionoptions.go
- encryptoptions.go
- estimatedcountoptions.go
- findoptions.go
- gridfsoptions.go
- indexoptions.go
- insertoptions.go
- listcollectionsoptions.go
- listdatabasesoptions.go
- lister.go
- loggeroptions.go
- mongooptions.go
- replaceoptions.go
- rewrapdatakeyoptions.go
- runcmdoptions.go
- searchindexoptions.go
- serverapioptions.go
- sessionoptions.go
- transactionoptions.go
- updateoptions.go