mongo-driver: go.mongodb.org/mongo-driver/mongo/options Index | Files

package options

import "go.mongodb.org/mongo-driver/mongo/options"

Index

Package Files

aggregateoptions.go bulkwriteoptions.go changestreamoptions.go clientoptions.go clientoptions_1_10.go collectionoptions.go countoptions.go dboptions.go deleteoptions.go distinctoptions.go estimatedcountoptions.go findoptions.go gridfsoptions.go indexoptions.go insertoptions.go listcollectionsoptions.go listdatabasesoptions.go mongooptions.go replaceoptions.go runcmdoptions.go sessionoptions.go transactionoptions.go updateoptions.go

Variables

var DefaultCausalConsistency = true

DefaultCausalConsistency is the default value for the CausalConsistency option.

var DefaultChunkSize int32 = 255 * 1024 // 255 KiB

DefaultChunkSize is the default size of each file chunk in bytes.

var DefaultName = "fs"

DefaultName is the default name for a GridFS bucket.

var DefaultOrdered = true

DefaultOrdered is the default order for a BulkWriteOptions struct created from BulkWrite.

var DefaultRevision int32 = -1

DefaultRevision is the default revision number for a download by name operation.

type AggregateOptions Uses

type AggregateOptions struct {
    AllowDiskUse             *bool          // Enables writing to temporary files. When set to true, aggregation stages can write data to the _tmp subdirectory in the dbPath directory
    BatchSize                *int32         // The number of documents to return per batch
    BypassDocumentValidation *bool          // If true, allows the write to opt-out of document level validation. This only applies when the $out stage is specified
    Collation                *Collation     // Specifies a collation
    MaxTime                  *time.Duration // The maximum amount of time to allow the query to run
    MaxAwaitTime             *time.Duration // The maximum amount of time for the server to wait on new documents to satisfy a tailable cursor query
    Comment                  *string        // Enables users to specify an arbitrary string to help trace the operation through the database profiler, currentOp and logs.
    Hint                     interface{}    // The index to use for the aggregation. The hint does not apply to $lookup and $graphLookup stages
}

AggregateOptions represents all possible options to the Aggregate() function.

func Aggregate Uses

func Aggregate() *AggregateOptions

Aggregate returns a pointer to a new AggregateOptions

func MergeAggregateOptions Uses

func MergeAggregateOptions(opts ...*AggregateOptions) *AggregateOptions

MergeAggregateOptions combines the argued AggregateOptions into a single AggregateOptions in a last-one-wins fashion

func (*AggregateOptions) SetAllowDiskUse Uses

func (ao *AggregateOptions) SetAllowDiskUse(b bool) *AggregateOptions

SetAllowDiskUse enables writing to temporary files. When set to true, aggregation stages can write data to the _tmp subdirectory in the dbPath directory

func (*AggregateOptions) SetBatchSize Uses

func (ao *AggregateOptions) SetBatchSize(i int32) *AggregateOptions

SetBatchSize specifies the number of documents to return per batch

func (*AggregateOptions) SetBypassDocumentValidation Uses

func (ao *AggregateOptions) SetBypassDocumentValidation(b bool) *AggregateOptions

SetBypassDocumentValidation allows the write to opt-out of document level validation. This only applies when the $out stage is specified Valid for server versions >= 3.2. For servers < 3.2, this option is ignored.

func (*AggregateOptions) SetCollation Uses

func (ao *AggregateOptions) SetCollation(c *Collation) *AggregateOptions

SetCollation specifies a collation. Valid for server versions >= 3.4

func (*AggregateOptions) SetComment Uses

func (ao *AggregateOptions) SetComment(s string) *AggregateOptions

SetComment enables users to specify an arbitrary string to help trace the operation through the database profiler, currentOp and logs.

func (*AggregateOptions) SetHint Uses

func (ao *AggregateOptions) SetHint(h interface{}) *AggregateOptions

SetHint specifies the index to use for the aggregation. The hint does not apply to $lookup and $graphLookup stages

func (*AggregateOptions) SetMaxAwaitTime Uses

func (ao *AggregateOptions) SetMaxAwaitTime(d time.Duration) *AggregateOptions

SetMaxAwaitTime specifies the maximum amount of time for the server to wait on new documents to satisfy a tailable cursor query For servers < 3.2, this option is ignored

func (*AggregateOptions) SetMaxTime Uses

func (ao *AggregateOptions) SetMaxTime(d time.Duration) *AggregateOptions

SetMaxTime specifies the maximum amount of time to allow the query to run

type ArrayFilters Uses

type ArrayFilters struct {
    Registry *bsoncodec.Registry // The registry to use for converting filters. Defaults to bson.DefaultRegistry.
    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 Uses

func (af *ArrayFilters) ToArray() ([]bson.Raw, error)

ToArray builds a []bson.Raw from the provided ArrayFilters.

type BucketOptions Uses

type BucketOptions struct {
    Name           *string                    // The bucket name. Defaults to "fs".
    ChunkSizeBytes *int32                     // The chunk size in bytes. Defaults to 255KB.
    WriteConcern   *writeconcern.WriteConcern // The write concern for the bucket. Defaults to the write concern of the database.
    ReadConcern    *readconcern.ReadConcern   // The read concern for the bucket. Defaults to the read concern of the database.
    ReadPreference *readpref.ReadPref         // The read preference for the bucket. Defaults to the read preference of the database.
}

BucketOptions represents all possible options to configure a GridFS bucket.

func GridFSBucket Uses

func GridFSBucket() *BucketOptions

GridFSBucket creates a new *BucketOptions

func MergeBucketOptions Uses

func MergeBucketOptions(opts ...*BucketOptions) *BucketOptions

MergeBucketOptions combines the given *BucketOptions into a single *BucketOptions. If the name or chunk size is not set in any of the given *BucketOptions, the resulting *BucketOptions will have name "fs" and chunk size 255KB.

func (*BucketOptions) SetChunkSizeBytes Uses

func (b *BucketOptions) SetChunkSizeBytes(i int32) *BucketOptions

SetChunkSizeBytes sets the chunk size in bytes for the bucket. Defaults to 255KB if not set.

func (*BucketOptions) SetName Uses

func (b *BucketOptions) SetName(name string) *BucketOptions

SetName sets the name for the bucket. Defaults to "fs" if not set.

func (*BucketOptions) SetReadConcern Uses

func (b *BucketOptions) SetReadConcern(rc *readconcern.ReadConcern) *BucketOptions

SetReadConcern sets the read concern for the bucket.

func (*BucketOptions) SetReadPreference Uses

func (b *BucketOptions) SetReadPreference(rp *readpref.ReadPref) *BucketOptions

SetReadPreference sets the read preference for the bucket.

func (*BucketOptions) SetWriteConcern Uses

func (b *BucketOptions) SetWriteConcern(wc *writeconcern.WriteConcern) *BucketOptions

SetWriteConcern sets the write concern for the bucket.

type BulkWriteOptions Uses

type BulkWriteOptions struct {
    BypassDocumentValidation *bool // If true, allows the write to opt out of document-level validation.
    Ordered                  *bool // If true, when a write fails, return without performing remaining writes. Defaults to true.
}

BulkWriteOptions represent all possible options for a bulkWrite operation.

func BulkWrite Uses

func BulkWrite() *BulkWriteOptions

BulkWrite creates a new *BulkWriteOptions

func MergeBulkWriteOptions Uses

func MergeBulkWriteOptions(opts ...*BulkWriteOptions) *BulkWriteOptions

MergeBulkWriteOptions combines the given *BulkWriteOptions into a single *BulkWriteOptions in a last one wins fashion.

func (*BulkWriteOptions) SetBypassDocumentValidation Uses

func (b *BulkWriteOptions) SetBypassDocumentValidation(bypass bool) *BulkWriteOptions

SetBypassDocumentValidation specifies if the write should opt out of document-level validation. Valid for server versions >= 3.2. For servers < 3.2, this option is ignored.

func (*BulkWriteOptions) SetOrdered Uses

func (b *BulkWriteOptions) SetOrdered(ordered bool) *BulkWriteOptions

SetOrdered configures the ordered option. If true, when a write fails, the function will return without attempting remaining writes. Defaults to true.

type ChangeStreamOptions Uses

type ChangeStreamOptions struct {
    BatchSize            *int32               // The number of documents to return per batch
    Collation            *Collation           // Specifies a collation
    FullDocument         *FullDocument        // When set to ‘updateLookup’, the change notification for partial updates will include both a delta describing the changes to the document, as well as a copy of the entire document that was changed from some time after the change occurred.
    MaxAwaitTime         *time.Duration       // The maximum amount of time for the server to wait on new documents to satisfy a change stream query
    ResumeAfter          interface{}          // Specifies the logical starting point for the new change stream
    StartAtOperationTime *primitive.Timestamp // Ensures that a change stream will only provide changes that occurred after a timestamp.
}

ChangeStreamOptions represents all possible options to a change stream

func ChangeStream Uses

func ChangeStream() *ChangeStreamOptions

ChangeStream returns a pointer to a new ChangeStreamOptions

func MergeChangeStreamOptions Uses

func MergeChangeStreamOptions(opts ...*ChangeStreamOptions) *ChangeStreamOptions

MergeChangeStreamOptions combines the argued ChangeStreamOptions into a single ChangeStreamOptions in a last-one-wins fashion

func (*ChangeStreamOptions) SetBatchSize Uses

func (cso *ChangeStreamOptions) SetBatchSize(i int32) *ChangeStreamOptions

SetBatchSize specifies the number of documents to return per batch

func (*ChangeStreamOptions) SetCollation Uses

func (cso *ChangeStreamOptions) SetCollation(c Collation) *ChangeStreamOptions

SetCollation specifies a collation

func (*ChangeStreamOptions) SetFullDocument Uses

func (cso *ChangeStreamOptions) SetFullDocument(fd FullDocument) *ChangeStreamOptions

SetFullDocument specifies the fullDocument option. When set to ‘updateLookup’, the change notification for partial updates will include both a delta describing the changes to the document, as well as a copy of the entire document that was changed from some time after the change occurred.

func (*ChangeStreamOptions) SetMaxAwaitTime Uses

func (cso *ChangeStreamOptions) SetMaxAwaitTime(d time.Duration) *ChangeStreamOptions

SetMaxAwaitTime specifies the maximum amount of time for the server to wait on new documents to satisfy a change stream query

func (*ChangeStreamOptions) SetResumeAfter Uses

func (cso *ChangeStreamOptions) SetResumeAfter(rt interface{}) *ChangeStreamOptions

SetResumeAfter specifies the logical starting point for the new change stream

func (*ChangeStreamOptions) SetStartAtOperationTime Uses

func (cso *ChangeStreamOptions) SetStartAtOperationTime(t *primitive.Timestamp) *ChangeStreamOptions

SetStartAtOperationTime ensures that a change stream will only provide changes that occurred after a specified timestamp.

type ClientOptions Uses

type ClientOptions struct {
    AppName                *string
    Auth                   *Credential
    ConnectTimeout         *time.Duration
    Compressors            []string
    Dialer                 ContextDialer
    HeartbeatInterval      *time.Duration
    Hosts                  []string
    LocalThreshold         *time.Duration
    MaxConnIdleTime        *time.Duration
    MaxPoolSize            *uint16
    Monitor                *event.CommandMonitor
    ReadConcern            *readconcern.ReadConcern
    ReadPreference         *readpref.ReadPref
    Registry               *bsoncodec.Registry
    ReplicaSet             *string
    RetryWrites            *bool
    ServerSelectionTimeout *time.Duration
    Direct                 *bool
    SocketTimeout          *time.Duration
    TLSConfig              *tls.Config
    WriteConcern           *writeconcern.WriteConcern
    ZlibLevel              *int

    // Adds an option for internal use only and should not be set. This option is deprecated and is
    // not part of the stability guarantee. It may be removed in the future.
    AuthenticateToAnything *bool
    // contains filtered or unexported fields
}

ClientOptions represents all possible options to configure a client.

func Client Uses

func Client() *ClientOptions

Client creates a new ClientOptions instance.

func MergeClientOptions Uses

func MergeClientOptions(opts ...*ClientOptions) *ClientOptions

MergeClientOptions combines the given connstring and *ClientOptions into a single *ClientOptions in a last one wins fashion. The given connstring will be used for the default options, which can be overwritten using the given *ClientOptions.

func (*ClientOptions) ApplyURI Uses

func (c *ClientOptions) ApplyURI(uri string) *ClientOptions

ApplyURI parses the provided connection string and sets the values and options accordingly.

Errors that occur in this method can be retrieved by calling Validate.

If the URI contains ssl=true this method will overwrite TLSConfig, even if there aren't any other tls options specified.

func (*ClientOptions) SetAppName Uses

func (c *ClientOptions) SetAppName(s string) *ClientOptions

SetAppName specifies the client application name. This value is used by MongoDB when it logs connection information and profile information, such as slow queries.

func (*ClientOptions) SetAuth Uses

func (c *ClientOptions) SetAuth(auth Credential) *ClientOptions

SetAuth sets the authentication options.

func (*ClientOptions) SetCompressors Uses

func (c *ClientOptions) SetCompressors(comps []string) *ClientOptions

SetCompressors sets the compressors that can be used when communicating with a server.

func (*ClientOptions) SetConnectTimeout Uses

func (c *ClientOptions) SetConnectTimeout(d time.Duration) *ClientOptions

SetConnectTimeout specifies the timeout for an initial connection to a server. If a custom Dialer is used, this method won't be set and the user is responsible for setting the ConnectTimeout for connections on the dialer themselves.

func (*ClientOptions) SetDialer Uses

func (c *ClientOptions) SetDialer(d ContextDialer) *ClientOptions

SetDialer specifies a custom dialer used to dial new connections to a server. If a custom dialer is not set, a net.Dialer with a 300 second keepalive time will be used by default.

func (*ClientOptions) SetDirect Uses

func (c *ClientOptions) SetDirect(b bool) *ClientOptions

SetDirect specifies whether the driver should connect directly to the server instead of auto-discovering other servers in the cluster.

func (*ClientOptions) SetHeartbeatInterval Uses

func (c *ClientOptions) SetHeartbeatInterval(d time.Duration) *ClientOptions

SetHeartbeatInterval specifies the interval to wait between server monitoring checks.

func (*ClientOptions) SetHosts Uses

func (c *ClientOptions) SetHosts(s []string) *ClientOptions

SetHosts specifies the initial list of addresses from which to discover the rest of the cluster.

func (*ClientOptions) SetLocalThreshold Uses

func (c *ClientOptions) SetLocalThreshold(d time.Duration) *ClientOptions

SetLocalThreshold specifies how far to distribute queries, beyond the server with the fastest round-trip time. If a server's roundtrip time is more than LocalThreshold slower than the the fastest, the driver will not send queries to that server.

func (*ClientOptions) SetMaxConnIdleTime Uses

func (c *ClientOptions) SetMaxConnIdleTime(d time.Duration) *ClientOptions

SetMaxConnIdleTime specifies the maximum number of milliseconds that a connection can remain idle in a connection pool before being removed and closed.

func (*ClientOptions) SetMaxPoolSize Uses

func (c *ClientOptions) SetMaxPoolSize(u uint16) *ClientOptions

SetMaxPoolSize specifies the max size of a server's connection pool.

func (*ClientOptions) SetMonitor Uses

func (c *ClientOptions) SetMonitor(m *event.CommandMonitor) *ClientOptions

SetMonitor specifies a command monitor used to see commands for a client.

func (*ClientOptions) SetReadConcern Uses

func (c *ClientOptions) SetReadConcern(rc *readconcern.ReadConcern) *ClientOptions

SetReadConcern specifies the read concern.

func (*ClientOptions) SetReadPreference Uses

func (c *ClientOptions) SetReadPreference(rp *readpref.ReadPref) *ClientOptions

SetReadPreference specifies the read preference.

func (*ClientOptions) SetRegistry Uses

func (c *ClientOptions) SetRegistry(registry *bsoncodec.Registry) *ClientOptions

SetRegistry specifies the bsoncodec.Registry.

func (*ClientOptions) SetReplicaSet Uses

func (c *ClientOptions) SetReplicaSet(s string) *ClientOptions

SetReplicaSet specifies the name of the replica set of the cluster.

func (*ClientOptions) SetRetryWrites Uses

func (c *ClientOptions) SetRetryWrites(b bool) *ClientOptions

SetRetryWrites specifies whether the client has retryable writes enabled.

func (*ClientOptions) SetServerSelectionTimeout Uses

func (c *ClientOptions) SetServerSelectionTimeout(d time.Duration) *ClientOptions

SetServerSelectionTimeout specifies a timeout in milliseconds to block for server selection.

func (*ClientOptions) SetSocketTimeout Uses

func (c *ClientOptions) SetSocketTimeout(d time.Duration) *ClientOptions

SetSocketTimeout specifies the time in milliseconds to attempt to send or receive on a socket before the attempt times out.

func (*ClientOptions) SetTLSConfig Uses

func (c *ClientOptions) SetTLSConfig(cfg *tls.Config) *ClientOptions

SetTLSConfig sets the tls.Config.

func (*ClientOptions) SetWriteConcern Uses

func (c *ClientOptions) SetWriteConcern(wc *writeconcern.WriteConcern) *ClientOptions

SetWriteConcern sets the write concern.

func (*ClientOptions) SetZlibLevel Uses

func (c *ClientOptions) SetZlibLevel(level int) *ClientOptions

SetZlibLevel sets the level for the zlib compressor.

func (*ClientOptions) Validate Uses

func (c *ClientOptions) Validate() error

Validate validates the client options. This method will return the first error found.

type Collation Uses

type Collation struct {
    Locale          string `bson:",omitempty"` // The locale
    CaseLevel       bool   `bson:",omitempty"` // The case level
    CaseFirst       string `bson:",omitempty"` // The case ordering
    Strength        int    `bson:",omitempty"` // The number of comparision levels to use
    NumericOrdering bool   `bson:",omitempty"` // Whether to order numbers based on numerical order and not collation order
    Alternate       string `bson:",omitempty"` // Whether spaces and punctuation are considered base characters
    MaxVariable     string `bson:",omitempty"` // Which characters are affected by alternate: "shifted"
    Normalization   bool   `bson:",omitempty"` // Causes text to be normalized into Unicode NFD
    Backwards       bool   `bson:",omitempty"` // Causes secondary differences to be considered in reverse order, as it is done in the French language
}

Collation allows users to specify language-specific rules for string comparison, such as rules for lettercase and accent marks.

func (*Collation) ToDocument Uses

func (co *Collation) ToDocument() bson.Raw

ToDocument converts the Collation to a bson.Raw.

type CollectionOptions Uses

type CollectionOptions struct {
    ReadConcern    *readconcern.ReadConcern   // The read concern for operations in the collection.
    WriteConcern   *writeconcern.WriteConcern // The write concern for operations in the collection.
    ReadPreference *readpref.ReadPref         // The read preference for operations in the collection.
    Registry       *bsoncodec.Registry        // The registry to be used to construct BSON encoders and decoders for the collection.
}

CollectionOptions represent all possible options to configure a Collection.

func Collection Uses

func Collection() *CollectionOptions

Collection creates a new CollectionOptions instance

func MergeCollectionOptions Uses

func MergeCollectionOptions(opts ...*CollectionOptions) *CollectionOptions

MergeCollectionOptions combines the *CollectionOptions arguments into a single *CollectionOptions in a last one wins fashion.

func (*CollectionOptions) SetReadConcern Uses

func (c *CollectionOptions) SetReadConcern(rc *readconcern.ReadConcern) *CollectionOptions

SetReadConcern sets the read concern for the collection.

func (*CollectionOptions) SetReadPreference Uses

func (c *CollectionOptions) SetReadPreference(rp *readpref.ReadPref) *CollectionOptions

SetReadPreference sets the read preference for the collection.

func (*CollectionOptions) SetRegistry Uses

func (c *CollectionOptions) SetRegistry(r *bsoncodec.Registry) *CollectionOptions

SetRegistry sets the bsoncodec Registry for the collection.

func (*CollectionOptions) SetWriteConcern Uses

func (c *CollectionOptions) SetWriteConcern(wc *writeconcern.WriteConcern) *CollectionOptions

SetWriteConcern sets the write concern for the collection.

type ContextDialer Uses

type ContextDialer interface {
    DialContext(ctx context.Context, network, address string) (net.Conn, error)
}

ContextDialer makes new network connections

type CountOptions Uses

type CountOptions struct {
    Collation *Collation     // Specifies a collation
    Hint      interface{}    // The index to use
    Limit     *int64         // The maximum number of documents to count
    MaxTime   *time.Duration // The maximum amount of time to allow the operation to run
    Skip      *int64         // The number of documents to skip before counting
}

CountOptions represents all possible options to the Count() function.

func Count Uses

func Count() *CountOptions

Count returns a pointer to a new CountOptions

func MergeCountOptions Uses

func MergeCountOptions(opts ...*CountOptions) *CountOptions

MergeCountOptions combines the argued CountOptions into a single CountOptions in a last-one-wins fashion

func (*CountOptions) SetCollation Uses

func (co *CountOptions) SetCollation(c *Collation) *CountOptions

SetCollation specifies a collation Valid for server versions >= 3.4

func (*CountOptions) SetHint Uses

func (co *CountOptions) SetHint(h interface{}) *CountOptions

SetHint specifies the index to use

func (*CountOptions) SetLimit Uses

func (co *CountOptions) SetLimit(i int64) *CountOptions

SetLimit specifies the maximum number of documents to count

func (*CountOptions) SetMaxTime Uses

func (co *CountOptions) SetMaxTime(d time.Duration) *CountOptions

SetMaxTime specifies the maximum amount of time to allow the operation to run

func (*CountOptions) SetSkip Uses

func (co *CountOptions) SetSkip(i int64) *CountOptions

SetSkip specifies the number of documents to skip before counting

type CreateIndexesOptions Uses

type CreateIndexesOptions struct {
    MaxTime *time.Duration // The maximum amount of time to allow the query to run.
}

CreateIndexesOptions represents all possible options for the CreateOne() and CreateMany() functions.

func CreateIndexes Uses

func CreateIndexes() *CreateIndexesOptions

CreateIndexes creates a new CreateIndexesOptions instance.

func MergeCreateIndexesOptions Uses

func MergeCreateIndexesOptions(opts ...*CreateIndexesOptions) *CreateIndexesOptions

MergeCreateIndexesOptions combines the given *CreateIndexesOptions into a single *CreateIndexesOptions in a last one wins fashion.

func (*CreateIndexesOptions) SetMaxTime Uses

func (c *CreateIndexesOptions) SetMaxTime(d time.Duration) *CreateIndexesOptions

SetMaxTime specifies the maximum amount of time to allow the query to run.

type Credential Uses

type Credential struct {
    AuthMechanism           string
    AuthMechanismProperties map[string]string
    AuthSource              string
    Username                string
    Password                string
    PasswordSet             bool
}

Credential holds auth options.

AuthMechanism indicates the mechanism to use for authentication. Supported values include "SCRAM-SHA-256", "SCRAM-SHA-1", "MONGODB-CR", "PLAIN", "GSSAPI", and "MONGODB-X509".

AuthMechanismProperties specifies additional configuration options which may be used by certain authentication mechanisms. Supported properties are: SERVICE_NAME: Specifies the name of the service. Defaults to mongodb. CANONICALIZE_HOST_NAME: If true, tells the driver to canonicalize the given hostname. Defaults to false. This property may not be used on Linux and Darwin systems and may not be used at the same time as SERVICE_HOST. SERVICE_REALM: Specifies the realm of the service. SERVICE_HOST: Specifies a hostname for GSSAPI authentication if it is different from the server's address. For authentication mechanisms besides GSSAPI, this property is ignored.

AuthSource specifies the database to authenticate against.

Username specifies the username that will be authenticated.

Password specifies the password used for authentication.

PasswordSet specifies if the password is actually set, since an empty password is a valid password.

type CursorType Uses

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 DatabaseOptions Uses

type DatabaseOptions struct {
    ReadConcern    *readconcern.ReadConcern   // The read concern for operations in the database.
    WriteConcern   *writeconcern.WriteConcern // The write concern for operations in the database.
    ReadPreference *readpref.ReadPref         // The read preference for operations in the database.
    Registry       *bsoncodec.Registry        // The registry to be used to construct BSON encoders and decoders for the database.
}

DatabaseOptions represent all possible options to configure a Database.

func Database Uses

func Database() *DatabaseOptions

Database creates a new DatabaseOptions instance

func MergeDatabaseOptions Uses

func MergeDatabaseOptions(opts ...*DatabaseOptions) *DatabaseOptions

MergeDatabaseOptions combines the *DatabaseOptions arguments into a single *DatabaseOptions in a last one wins fashion.

func (*DatabaseOptions) SetReadConcern Uses

func (d *DatabaseOptions) SetReadConcern(rc *readconcern.ReadConcern) *DatabaseOptions

SetReadConcern sets the read concern for the database.

func (*DatabaseOptions) SetReadPreference Uses

func (d *DatabaseOptions) SetReadPreference(rp *readpref.ReadPref) *DatabaseOptions

SetReadPreference sets the read preference for the database.

func (*DatabaseOptions) SetRegistry Uses

func (d *DatabaseOptions) SetRegistry(r *bsoncodec.Registry) *DatabaseOptions

SetRegistry sets the bsoncodec Registry for the database.

func (*DatabaseOptions) SetWriteConcern Uses

func (d *DatabaseOptions) SetWriteConcern(wc *writeconcern.WriteConcern) *DatabaseOptions

SetWriteConcern sets the write concern for the database.

type DeleteOptions Uses

type DeleteOptions struct {
    Collation *Collation // Specifies a collation
}

DeleteOptions represents all possible options to the DeleteOne() and DeleteMany() functions.

func Delete Uses

func Delete() *DeleteOptions

Delete returns a pointer to a new DeleteOptions

func MergeDeleteOptions Uses

func MergeDeleteOptions(opts ...*DeleteOptions) *DeleteOptions

MergeDeleteOptions combines the argued DeleteOptions into a single DeleteOptions in a last-one-wins fashion

func (*DeleteOptions) SetCollation Uses

func (do *DeleteOptions) SetCollation(c *Collation) *DeleteOptions

SetCollation specifies a collation Valid for servers >= 3.4.

type DistinctOptions Uses

type DistinctOptions struct {
    Collation *Collation     // Specifies a collation
    MaxTime   *time.Duration // The maximum amount of time to allow the operation to run
}

DistinctOptions represents all possible options to the Distinct() function.

func Distinct Uses

func Distinct() *DistinctOptions

Distinct returns a pointer to a new DistinctOptions

func MergeDistinctOptions Uses

func MergeDistinctOptions(opts ...*DistinctOptions) *DistinctOptions

MergeDistinctOptions combines the argued DistinctOptions into a single DistinctOptions in a last-one-wins fashion

func (*DistinctOptions) SetCollation Uses

func (do *DistinctOptions) SetCollation(c *Collation) *DistinctOptions

SetCollation specifies a collation Valid for server versions >= 3.4

func (*DistinctOptions) SetMaxTime Uses

func (do *DistinctOptions) SetMaxTime(d time.Duration) *DistinctOptions

SetMaxTime specifies the maximum amount of time to allow the operation to run

type DropIndexesOptions Uses

type DropIndexesOptions struct {
    MaxTime *time.Duration
}

DropIndexesOptions represents all possible options for the DropIndexes() function.

func DropIndexes Uses

func DropIndexes() *DropIndexesOptions

DropIndexes creates a new DropIndexesOptions instance.

func MergeDropIndexesOptions Uses

func MergeDropIndexesOptions(opts ...*DropIndexesOptions) *DropIndexesOptions

MergeDropIndexesOptions combines the given *DropIndexesOptions into a single *DropIndexesOptions in a last one wins fashion.

func (*DropIndexesOptions) SetMaxTime Uses

func (d *DropIndexesOptions) SetMaxTime(duration time.Duration) *DropIndexesOptions

SetMaxTime specifies the maximum amount of time to allow the query to run.

type EstimatedDocumentCountOptions Uses

type EstimatedDocumentCountOptions struct {
    MaxTime *time.Duration // The maximum amount of time to allow the operation to run
}

EstimatedDocumentCountOptions represents all possible options to the EstimatedDocumentCount() function.

func EstimatedDocumentCount Uses

func EstimatedDocumentCount() *EstimatedDocumentCountOptions

EstimatedDocumentCount returns a pointer to a new EstimatedDocumentCountOptions

func MergeEstimatedDocumentCountOptions Uses

func MergeEstimatedDocumentCountOptions(opts ...*EstimatedDocumentCountOptions) *EstimatedDocumentCountOptions

MergeEstimatedDocumentCountOptions combines the given *EstimatedDocumentCountOptions into a single *EstimatedDocumentCountOptions in a last one wins fashion.

func (*EstimatedDocumentCountOptions) SetMaxTime Uses

func (eco *EstimatedDocumentCountOptions) SetMaxTime(d time.Duration) *EstimatedDocumentCountOptions

SetMaxTime specifies the maximum amount of time to allow the operation to run

type FindOneAndDeleteOptions Uses

type FindOneAndDeleteOptions struct {
    Collation  *Collation     // Specifies a collation to be used
    MaxTime    *time.Duration // Specifies the maximum amount of time to allow the query to run.
    Projection interface{}    // Limits the fields returned for all documents.
    Sort       interface{}    // Specifies the order in which to return results.
}

FindOneAndDeleteOptions represent all possible options to the FindOneAndDelete() function.

func FindOneAndDelete Uses

func FindOneAndDelete() *FindOneAndDeleteOptions

FindOneAndDelete creates a new FindOneAndDeleteOptions instance.

func MergeFindOneAndDeleteOptions Uses

func MergeFindOneAndDeleteOptions(opts ...*FindOneAndDeleteOptions) *FindOneAndDeleteOptions

MergeFindOneAndDeleteOptions combines the argued FindOneAndDeleteOptions into a single FindOneAndDeleteOptions in a last-one-wins fashion

func (*FindOneAndDeleteOptions) SetCollation Uses

func (f *FindOneAndDeleteOptions) SetCollation(collation *Collation) *FindOneAndDeleteOptions

SetCollation specifies a Collation to use for the Find operation. Valid for server versions >= 3.4

func (*FindOneAndDeleteOptions) SetMaxTime Uses

func (f *FindOneAndDeleteOptions) SetMaxTime(d time.Duration) *FindOneAndDeleteOptions

SetMaxTime specifies the max time to allow the query to run.

func (*FindOneAndDeleteOptions) SetProjection Uses

func (f *FindOneAndDeleteOptions) SetProjection(projection interface{}) *FindOneAndDeleteOptions

SetProjection adds an option to limit the fields returned for all documents.

func (*FindOneAndDeleteOptions) SetSort Uses

func (f *FindOneAndDeleteOptions) SetSort(sort interface{}) *FindOneAndDeleteOptions

SetSort specifies the order in which to return documents.

type FindOneAndReplaceOptions Uses

type FindOneAndReplaceOptions struct {
    BypassDocumentValidation *bool           // If true, allows the write to opt out of document-level validation.
    Collation                *Collation      // Specifies a collation to be used
    MaxTime                  *time.Duration  // Specifies the maximum amount of time to allow the query to run.
    Projection               interface{}     // Limits the fields returned for all documents.
    ReturnDocument           *ReturnDocument // Specifies whether the original or updated document should be returned.
    Sort                     interface{}     // Specifies the order in which to return results.
    Upsert                   *bool           // If true, creates a a new document if no document matches the query.
}

FindOneAndReplaceOptions represent all possible options to the FindOneAndReplace() function.

func FindOneAndReplace Uses

func FindOneAndReplace() *FindOneAndReplaceOptions

FindOneAndReplace creates a new FindOneAndReplaceOptions instance.

func MergeFindOneAndReplaceOptions Uses

func MergeFindOneAndReplaceOptions(opts ...*FindOneAndReplaceOptions) *FindOneAndReplaceOptions

MergeFindOneAndReplaceOptions combines the argued FindOneAndReplaceOptions into a single FindOneAndReplaceOptions in a last-one-wins fashion

func (*FindOneAndReplaceOptions) SetBypassDocumentValidation Uses

func (f *FindOneAndReplaceOptions) SetBypassDocumentValidation(b bool) *FindOneAndReplaceOptions

SetBypassDocumentValidation specifies whether or not the write should opt out of document-level validation. Valid for server versions >= 3.2. For servers < 3.2, this option is ignored.

func (*FindOneAndReplaceOptions) SetCollation Uses

func (f *FindOneAndReplaceOptions) SetCollation(collation *Collation) *FindOneAndReplaceOptions

SetCollation specifies a Collation to use for the Find operation.

func (*FindOneAndReplaceOptions) SetMaxTime Uses

func (f *FindOneAndReplaceOptions) SetMaxTime(d time.Duration) *FindOneAndReplaceOptions

SetMaxTime specifies the max time to allow the query to run.

func (*FindOneAndReplaceOptions) SetProjection Uses

func (f *FindOneAndReplaceOptions) SetProjection(projection interface{}) *FindOneAndReplaceOptions

SetProjection adds an option to limit the fields returned for all documents.

func (*FindOneAndReplaceOptions) SetReturnDocument Uses

func (f *FindOneAndReplaceOptions) SetReturnDocument(rd ReturnDocument) *FindOneAndReplaceOptions

SetReturnDocument specifies whether the original or updated document should be returned. If set to Before, the original document will be returned. If set to After, the updated document will be returned.

func (*FindOneAndReplaceOptions) SetSort Uses

func (f *FindOneAndReplaceOptions) SetSort(sort interface{}) *FindOneAndReplaceOptions

SetSort specifies the order in which to return documents.

func (*FindOneAndReplaceOptions) SetUpsert Uses

func (f *FindOneAndReplaceOptions) SetUpsert(b bool) *FindOneAndReplaceOptions

SetUpsert specifies if a new document should be created if no document matches the query.

type FindOneAndUpdateOptions Uses

type FindOneAndUpdateOptions struct {
    ArrayFilters             *ArrayFilters   // A set of filters specifying to which array elements an update should apply.
    BypassDocumentValidation *bool           // If true, allows the write to opt out of document-level validation.
    Collation                *Collation      // Specifies a collation to be used
    MaxTime                  *time.Duration  // Specifies the maximum amount of time to allow the query to run.
    Projection               interface{}     // Limits the fields returned for all documents.
    ReturnDocument           *ReturnDocument // Specifies whether the original or updated document should be returned.
    Sort                     interface{}     // Specifies the order in which to return results.
    Upsert                   *bool           // If true, creates a a new document if no document matches the query.
}

FindOneAndUpdateOptions represent all possible options to the FindOneAndUpdate() function.

func FindOneAndUpdate Uses

func FindOneAndUpdate() *FindOneAndUpdateOptions

FindOneAndUpdate creates a new FindOneAndUpdateOptions instance.

func MergeFindOneAndUpdateOptions Uses

func MergeFindOneAndUpdateOptions(opts ...*FindOneAndUpdateOptions) *FindOneAndUpdateOptions

MergeFindOneAndUpdateOptions combines the argued FindOneAndUpdateOptions into a single FindOneAndUpdateOptions in a last-one-wins fashion

func (*FindOneAndUpdateOptions) SetArrayFilters Uses

func (f *FindOneAndUpdateOptions) SetArrayFilters(filters ArrayFilters) *FindOneAndUpdateOptions

SetArrayFilters specifies a set of filters, which

func (*FindOneAndUpdateOptions) SetBypassDocumentValidation Uses

func (f *FindOneAndUpdateOptions) SetBypassDocumentValidation(b bool) *FindOneAndUpdateOptions

SetBypassDocumentValidation sets filters that specify to which array elements an update should apply.

func (*FindOneAndUpdateOptions) SetCollation Uses

func (f *FindOneAndUpdateOptions) SetCollation(collation *Collation) *FindOneAndUpdateOptions

SetCollation specifies a Collation to use for the Find operation.

func (*FindOneAndUpdateOptions) SetMaxTime Uses

func (f *FindOneAndUpdateOptions) SetMaxTime(d time.Duration) *FindOneAndUpdateOptions

SetMaxTime specifies the max time to allow the query to run.

func (*FindOneAndUpdateOptions) SetProjection Uses

func (f *FindOneAndUpdateOptions) SetProjection(projection interface{}) *FindOneAndUpdateOptions

SetProjection adds an option to limit the fields returned for all documents.

func (*FindOneAndUpdateOptions) SetReturnDocument Uses

func (f *FindOneAndUpdateOptions) SetReturnDocument(rd ReturnDocument) *FindOneAndUpdateOptions

SetReturnDocument specifies whether the original or updated document should be returned. If set to Before, the original document will be returned. If set to After, the updated document will be returned.

func (*FindOneAndUpdateOptions) SetSort Uses

func (f *FindOneAndUpdateOptions) SetSort(sort interface{}) *FindOneAndUpdateOptions

SetSort specifies the order in which to return documents.

func (*FindOneAndUpdateOptions) SetUpsert Uses

func (f *FindOneAndUpdateOptions) SetUpsert(b bool) *FindOneAndUpdateOptions

SetUpsert specifies if a new document should be created if no document matches the query.

type FindOneOptions Uses

type FindOneOptions struct {
    AllowPartialResults *bool          // If true, allows partial results to be returned if some shards are down.
    BatchSize           *int32         // Specifies the number of documents to return in every batch.
    Collation           *Collation     // Specifies a collation to be used
    Comment             *string        // Specifies a string to help trace the operation through the database.
    CursorType          *CursorType    // Specifies the type of cursor to use
    Hint                interface{}    // Specifies the index to use.
    Max                 interface{}    // Sets an exclusive upper bound for a specific index
    MaxAwaitTime        *time.Duration // Specifies the maximum amount of time for the server to wait on new documents.
    MaxTime             *time.Duration // Specifies the maximum amount of time to allow the query to run.
    Min                 interface{}    // Specifies the inclusive lower bound for a specific index.
    NoCursorTimeout     *bool          // If true, prevents cursors from timing out after an inactivity period.
    OplogReplay         *bool          // Adds an option for internal use only and should not be set.
    Projection          interface{}    // Limits the fields returned for all documents.
    ReturnKey           *bool          // If true, only returns index keys for all result documents.
    ShowRecordID        *bool          // If true, a $recordId field with the record identifier will be added to the returned documents.
    Skip                *int64         // Specifies the number of documents to skip before returning
    Snapshot            *bool          // If true, prevents the cursor from returning a document more than once because of an intervening write operation.
    Sort                interface{}    // Specifies the order in which to return results.
}

FindOneOptions represent all possible options to the FindOne() function.

func FindOne Uses

func FindOne() *FindOneOptions

FindOne creates a new FindOneOptions instance.

func MergeFindOneOptions Uses

func MergeFindOneOptions(opts ...*FindOneOptions) *FindOneOptions

MergeFindOneOptions combines the argued FindOneOptions into a single FindOneOptions in a last-one-wins fashion

func (*FindOneOptions) SetAllowPartialResults Uses

func (f *FindOneOptions) SetAllowPartialResults(b bool) *FindOneOptions

SetAllowPartialResults sets whether partial results can be returned if some shards are down.

func (*FindOneOptions) SetBatchSize Uses

func (f *FindOneOptions) SetBatchSize(i int32) *FindOneOptions

SetBatchSize sets the number of documents to return in each batch.

func (*FindOneOptions) SetCollation Uses

func (f *FindOneOptions) SetCollation(collation *Collation) *FindOneOptions

SetCollation specifies a Collation to use for the Find operation.

func (*FindOneOptions) SetComment Uses

func (f *FindOneOptions) SetComment(comment string) *FindOneOptions

SetComment specifies a string to help trace the operation through the database.

func (*FindOneOptions) SetCursorType Uses

func (f *FindOneOptions) SetCursorType(ct CursorType) *FindOneOptions

SetCursorType specifes the type of cursor to use.

func (*FindOneOptions) SetHint Uses

func (f *FindOneOptions) SetHint(hint interface{}) *FindOneOptions

SetHint specifies the index to use.

func (*FindOneOptions) SetMax Uses

func (f *FindOneOptions) SetMax(max interface{}) *FindOneOptions

SetMax specifies an exclusive upper bound for a specific index.

func (*FindOneOptions) SetMaxAwaitTime Uses

func (f *FindOneOptions) SetMaxAwaitTime(d time.Duration) *FindOneOptions

SetMaxAwaitTime specifies the max amount of time for the server to wait on new documents. For server versions < 3.2, this option is ignored.

func (*FindOneOptions) SetMaxTime Uses

func (f *FindOneOptions) SetMaxTime(d time.Duration) *FindOneOptions

SetMaxTime specifies the max time to allow the query to run.

func (*FindOneOptions) SetMin Uses

func (f *FindOneOptions) SetMin(min interface{}) *FindOneOptions

SetMin specifies the inclusive lower bound for a specific index.

func (*FindOneOptions) SetNoCursorTimeout Uses

func (f *FindOneOptions) SetNoCursorTimeout(b bool) *FindOneOptions

SetNoCursorTimeout specifies whether or not cursors should time out after a period of inactivity.

func (*FindOneOptions) SetOplogReplay Uses

func (f *FindOneOptions) SetOplogReplay(b bool) *FindOneOptions

SetOplogReplay adds an option for internal use only and should not be set.

func (*FindOneOptions) SetProjection Uses

func (f *FindOneOptions) SetProjection(projection interface{}) *FindOneOptions

SetProjection adds an option to limit the fields returned for all documents.

func (*FindOneOptions) SetReturnKey Uses

func (f *FindOneOptions) SetReturnKey(b bool) *FindOneOptions

SetReturnKey adds an option to only return index keys for all result documents.

func (*FindOneOptions) SetShowRecordID Uses

func (f *FindOneOptions) SetShowRecordID(b bool) *FindOneOptions

SetShowRecordID adds an option to determine whether to return the record identifier for each document. If true, a $recordId field will be added to each returned document.

func (*FindOneOptions) SetSkip Uses

func (f *FindOneOptions) SetSkip(i int64) *FindOneOptions

SetSkip specifies the number of documents to skip before returning.

func (*FindOneOptions) SetSnapshot Uses

func (f *FindOneOptions) SetSnapshot(b bool) *FindOneOptions

SetSnapshot prevents the cursor from returning a document more than once because of an intervening write operation.

func (*FindOneOptions) SetSort Uses

func (f *FindOneOptions) SetSort(sort interface{}) *FindOneOptions

SetSort specifies the order in which to return documents.

type FindOptions Uses

type FindOptions struct {
    AllowPartialResults *bool          // If true, allows partial results to be returned if some shards are down.
    BatchSize           *int32         // Specifies the number of documents to return in every batch.
    Collation           *Collation     // Specifies a collation to be used
    Comment             *string        // Specifies a string to help trace the operation through the database.
    CursorType          *CursorType    // Specifies the type of cursor to use
    Hint                interface{}    // Specifies the index to use.
    Limit               *int64         // Sets a limit on the number of results to return.
    Max                 interface{}    // Sets an exclusive upper bound for a specific index
    MaxAwaitTime        *time.Duration // Specifies the maximum amount of time for the server to wait on new documents.
    MaxTime             *time.Duration // Specifies the maximum amount of time to allow the query to run.
    Min                 interface{}    // Specifies the inclusive lower bound for a specific index.
    NoCursorTimeout     *bool          // If true, prevents cursors from timing out after an inactivity period.
    OplogReplay         *bool          // Adds an option for internal use only and should not be set.
    Projection          interface{}    // Limits the fields returned for all documents.
    ReturnKey           *bool          // If true, only returns index keys for all result documents.
    ShowRecordID        *bool          // If true, a $recordId field with the record identifier will be added to the returned documents.
    Skip                *int64         // Specifies the number of documents to skip before returning
    Snapshot            *bool          // If true, prevents the cursor from returning a document more than once because of an intervening write operation.
    Sort                interface{}    // Specifies the order in which to return results.
}

FindOptions represent all possible options to the Find() function.

func Find Uses

func Find() *FindOptions

Find creates a new FindOptions instance.

func MergeFindOptions Uses

func MergeFindOptions(opts ...*FindOptions) *FindOptions

MergeFindOptions combines the argued FindOptions into a single FindOptions in a last-one-wins fashion

func (*FindOptions) SetAllowPartialResults Uses

func (f *FindOptions) SetAllowPartialResults(b bool) *FindOptions

SetAllowPartialResults sets whether partial results can be returned if some shards are down. For server versions < 3.2, this defaults to false.

func (*FindOptions) SetBatchSize Uses

func (f *FindOptions) SetBatchSize(i int32) *FindOptions

SetBatchSize sets the number of documents to return in each batch.

func (*FindOptions) SetCollation Uses

func (f *FindOptions) SetCollation(collation *Collation) *FindOptions

SetCollation specifies a Collation to use for the Find operation. Valid for server versions >= 3.4

func (*FindOptions) SetComment Uses

func (f *FindOptions) SetComment(comment string) *FindOptions

SetComment specifies a string to help trace the operation through the database.

func (*FindOptions) SetCursorType Uses

func (f *FindOptions) SetCursorType(ct CursorType) *FindOptions

SetCursorType specifes the type of cursor to use.

func (*FindOptions) SetHint Uses

func (f *FindOptions) SetHint(hint interface{}) *FindOptions

SetHint specifies the index to use.

func (*FindOptions) SetLimit Uses

func (f *FindOptions) SetLimit(i int64) *FindOptions

SetLimit specifies a limit on the number of results. A negative limit implies that only 1 batch should be returned.

func (*FindOptions) SetMax Uses

func (f *FindOptions) SetMax(max interface{}) *FindOptions

SetMax specifies an exclusive upper bound for a specific index.

func (*FindOptions) SetMaxAwaitTime Uses

func (f *FindOptions) SetMaxAwaitTime(d time.Duration) *FindOptions

SetMaxAwaitTime specifies the max amount of time for the server to wait on new documents. If the cursor type is not TailableAwait, this option is ignored. For server versions < 3.2, this option is ignored.

func (*FindOptions) SetMaxTime Uses

func (f *FindOptions) SetMaxTime(d time.Duration) *FindOptions

SetMaxTime specifies the max time to allow the query to run.

func (*FindOptions) SetMin Uses

func (f *FindOptions) SetMin(min interface{}) *FindOptions

SetMin specifies the inclusive lower bound for a specific index.

func (*FindOptions) SetNoCursorTimeout Uses

func (f *FindOptions) SetNoCursorTimeout(b bool) *FindOptions

SetNoCursorTimeout specifies whether or not cursors should time out after a period of inactivity. For server versions < 3.2, this defaults to false.

func (*FindOptions) SetOplogReplay Uses

func (f *FindOptions) SetOplogReplay(b bool) *FindOptions

SetOplogReplay adds an option for internal use only and should not be set. For server versions < 3.2, this defaults to false.

func (*FindOptions) SetProjection Uses

func (f *FindOptions) SetProjection(projection interface{}) *FindOptions

SetProjection adds an option to limit the fields returned for all documents.

func (*FindOptions) SetReturnKey Uses

func (f *FindOptions) SetReturnKey(b bool) *FindOptions

SetReturnKey adds an option to only return index keys for all result documents.

func (*FindOptions) SetShowRecordID Uses

func (f *FindOptions) SetShowRecordID(b bool) *FindOptions

SetShowRecordID adds an option to determine whether to return the record identifier for each document. If true, a $recordId field will be added to each returned document.

func (*FindOptions) SetSkip Uses

func (f *FindOptions) SetSkip(i int64) *FindOptions

SetSkip specifies the number of documents to skip before returning. For server versions < 3.2, this defaults to 0.

func (*FindOptions) SetSnapshot Uses

func (f *FindOptions) SetSnapshot(b bool) *FindOptions

SetSnapshot prevents the cursor from returning a document more than once because of an intervening write operation.

func (*FindOptions) SetSort Uses

func (f *FindOptions) SetSort(sort interface{}) *FindOptions

SetSort specifies the order in which to return documents.

type FullDocument Uses

type FullDocument string

FullDocument specifies whether a change stream should include a copy of the entire document that was changed from some time after the change occurred.

const (
    // Default does not include a document copy
    Default FullDocument = "default"
    // UpdateLookup includes a delta describing the changes to the document and a copy of the entire document that
    // was changed
    UpdateLookup FullDocument = "updateLookup"
)

type GridFSFindOptions Uses

type GridFSFindOptions struct {
    BatchSize       *int32
    Limit           *int32
    MaxTime         *time.Duration
    NoCursorTimeout *bool
    Skip            *int32
    Sort            interface{}
}

GridFSFindOptions represents all options for a GridFS find operation.

func GridFSFind Uses

func GridFSFind() *GridFSFindOptions

GridFSFind creates a new GridFSFindOptions instance.

func MergeGridFSFindOptions Uses

func MergeGridFSFindOptions(opts ...*GridFSFindOptions) *GridFSFindOptions

MergeGridFSFindOptions combines the argued GridFSFindOptions into a single GridFSFindOptions in a last-one-wins fashion

func (*GridFSFindOptions) SetBatchSize Uses

func (f *GridFSFindOptions) SetBatchSize(i int32) *GridFSFindOptions

SetBatchSize sets the number of documents to return in each batch.

func (*GridFSFindOptions) SetLimit Uses

func (f *GridFSFindOptions) SetLimit(i int32) *GridFSFindOptions

SetLimit specifies a limit on the number of results. A negative limit implies that only 1 batch should be returned.

func (*GridFSFindOptions) SetMaxTime Uses

func (f *GridFSFindOptions) SetMaxTime(d time.Duration) *GridFSFindOptions

SetMaxTime specifies the max time to allow the query to run.

func (*GridFSFindOptions) SetNoCursorTimeout Uses

func (f *GridFSFindOptions) SetNoCursorTimeout(b bool) *GridFSFindOptions

SetNoCursorTimeout specifies whether or not cursors should time out after a period of inactivity.

func (*GridFSFindOptions) SetSkip Uses

func (f *GridFSFindOptions) SetSkip(i int32) *GridFSFindOptions

SetSkip specifies the number of documents to skip before returning.

func (*GridFSFindOptions) SetSort Uses

func (f *GridFSFindOptions) SetSort(sort interface{}) *GridFSFindOptions

SetSort specifies the order in which to return documents.

type IndexOptions Uses

type IndexOptions struct {
    Background              *bool
    ExpireAfterSeconds      *int32
    Name                    *string
    Sparse                  *bool
    StorageEngine           interface{}
    Unique                  *bool
    Version                 *int32
    DefaultLanguage         *string
    LanguageOverride        *string
    TextVersion             *int32
    Weights                 interface{}
    SphereVersion           *int32
    Bits                    *int32
    Max                     *float64
    Min                     *float64
    BucketSize              *int32
    PartialFilterExpression interface{}
    Collation               *Collation
}

IndexOptions represents all possible options to configure a new index.

func Index Uses

func Index() *IndexOptions

Index creates a new *IndexOptions

func MergeIndexOptions Uses

func MergeIndexOptions(opts ...*IndexOptions) *IndexOptions

MergeIndexOptions combines the given *IndexOptions into a single *IndexOptions in a last one wins fashion.

func (*IndexOptions) SetBackground Uses

func (i *IndexOptions) SetBackground(background bool) *IndexOptions

SetBackground sets the background option. If true, the server will create the index in the background and not block other tasks

func (*IndexOptions) SetBits Uses

func (i *IndexOptions) SetBits(bits int32) *IndexOptions

SetBits specifies the precision of the stored geo hash in the 2d index, from 1 to 32.

func (*IndexOptions) SetBucketSize Uses

func (i *IndexOptions) SetBucketSize(bucketSize int32) *IndexOptions

SetBucketSize specifies number of units within which to group the location values in a geo haystack index.

func (*IndexOptions) SetCollation Uses

func (i *IndexOptions) SetCollation(collation *Collation) *IndexOptions

SetCollation specifies a Collation to use for the operation. Valid for server versions >= 3.4

func (*IndexOptions) SetDefaultLanguage Uses

func (i *IndexOptions) SetDefaultLanguage(language string) *IndexOptions

SetDefaultLanguage specifies the default language for text indexes. If not set, this will default to english.

func (*IndexOptions) SetExpireAfterSeconds Uses

func (i *IndexOptions) SetExpireAfterSeconds(seconds int32) *IndexOptions

SetExpireAfterSeconds specifies the number of seconds for a document to remain in a collection.

func (*IndexOptions) SetLanguageOverride Uses

func (i *IndexOptions) SetLanguageOverride(override string) *IndexOptions

SetLanguageOverride specifies the field in the document to override the language.

func (*IndexOptions) SetMax Uses

func (i *IndexOptions) SetMax(max float64) *IndexOptions

SetMax specifies the maximum boundary for latitude and longitude in the 2d index.

func (*IndexOptions) SetMin Uses

func (i *IndexOptions) SetMin(min float64) *IndexOptions

SetMin specifies the minimum boundary for latitude and longitude in the 2d index.

func (*IndexOptions) SetName Uses

func (i *IndexOptions) SetName(name string) *IndexOptions

SetName specifies a name for the index. If not set, a name will be generated in the format "[field]_[direction]". If multiple indexes are created for the same key pattern with different collations, a name must be provided to avoid ambiguity.

func (*IndexOptions) SetPartialFilterExpression Uses

func (i *IndexOptions) SetPartialFilterExpression(expression interface{}) *IndexOptions

SetPartialFilterExpression specifies a filter for use in a partial index. Only documents that match the filter expression are included in the index.

func (*IndexOptions) SetSparse Uses

func (i *IndexOptions) SetSparse(sparse bool) *IndexOptions

SetSparse sets the sparse option. If true, the index will only reference documents with the specified field in the index.

func (*IndexOptions) SetSphereVersion Uses

func (i *IndexOptions) SetSphereVersion(version int32) *IndexOptions

SetSphereVersion specifies the 2dsphere index version number. MongoDB version 2.4 can only support version 1. MongoDB versions 2.6 and higher can support versions 1 or 2.

func (*IndexOptions) SetStorageEngine Uses

func (i *IndexOptions) SetStorageEngine(engine interface{}) *IndexOptions

SetStorageEngine specifies the storage engine to use. Valid for server versions >= 3.0

func (*IndexOptions) SetTextVersion Uses

func (i *IndexOptions) SetTextVersion(version int32) *IndexOptions

SetTextVersion specifies the text index version number. MongoDB version 2.4 can only support version 1. MongoDB versions 2.6 and higher can support versions 1 or 2.

func (*IndexOptions) SetUnique Uses

func (i *IndexOptions) SetUnique(unique bool) *IndexOptions

SetUnique forces the index to be unique.

func (*IndexOptions) SetVersion Uses

func (i *IndexOptions) SetVersion(version int32) *IndexOptions

SetVersion specifies the index version number, either 0 or 1.

func (*IndexOptions) SetWeights Uses

func (i *IndexOptions) SetWeights(weights interface{}) *IndexOptions

SetWeights specifies fields in the index and their corresponding weight values.

type InsertManyOptions Uses

type InsertManyOptions struct {
    BypassDocumentValidation *bool // If true, allows the write to opt-out of document level validation
    Ordered                  *bool // If true, when an insert fails, return without performing the remaining inserts. Defaults to true.
}

InsertManyOptions represents all possible options to the InsertMany() function.

func InsertMany Uses

func InsertMany() *InsertManyOptions

InsertMany returns a pointer to a new InsertManyOptions

func MergeInsertManyOptions Uses

func MergeInsertManyOptions(opts ...*InsertManyOptions) *InsertManyOptions

MergeInsertManyOptions combines the argued InsertManyOptions into a single InsertManyOptions in a last-one-wins fashion

func (*InsertManyOptions) SetBypassDocumentValidation Uses

func (imo *InsertManyOptions) SetBypassDocumentValidation(b bool) *InsertManyOptions

SetBypassDocumentValidation allows the write to opt-out of document level validation. Valid for server versions >= 3.2. For servers < 3.2, this option is ignored.

func (*InsertManyOptions) SetOrdered Uses

func (imo *InsertManyOptions) SetOrdered(b bool) *InsertManyOptions

SetOrdered configures the ordered option. If true, when a write fails, the function will return without attempting remaining writes. Defaults to true.

type InsertOneOptions Uses

type InsertOneOptions struct {
    BypassDocumentValidation *bool // If true, allows the write to opt-out of document level validation
}

InsertOneOptions represents all possible options to the InsertOne() function.

func InsertOne Uses

func InsertOne() *InsertOneOptions

InsertOne returns a pointer to a new InsertOneOptions

func MergeInsertOneOptions Uses

func MergeInsertOneOptions(opts ...*InsertOneOptions) *InsertOneOptions

MergeInsertOneOptions combines the argued InsertOneOptions into a single InsertOneOptions in a last-one-wins fashion

func (*InsertOneOptions) SetBypassDocumentValidation Uses

func (ioo *InsertOneOptions) SetBypassDocumentValidation(b bool) *InsertOneOptions

SetBypassDocumentValidation allows the write to opt-out of document level validation. Valid for server versions >= 3.2. For servers < 3.2, this option is ignored.

type ListCollectionsOptions Uses

type ListCollectionsOptions struct {
    NameOnly *bool // If true, only the collection names will be returned.
}

ListCollectionsOptions represents all possible options for a listCollections command.

func ListCollections Uses

func ListCollections() *ListCollectionsOptions

ListCollections creates a new *ListCollectionsOptions

func MergeListCollectionsOptions Uses

func MergeListCollectionsOptions(opts ...*ListCollectionsOptions) *ListCollectionsOptions

MergeListCollectionsOptions combines the given *ListCollectionsOptions into a single *ListCollectionsOptions in a last one wins fashion.

func (*ListCollectionsOptions) SetNameOnly Uses

func (lc *ListCollectionsOptions) SetNameOnly(b bool) *ListCollectionsOptions

SetNameOnly specifies whether to return only the collection names.

type ListDatabasesOptions Uses

type ListDatabasesOptions struct {
    NameOnly *bool // If true, only the database names will be returned.
}

ListDatabasesOptions represents all possible options for a listDatabases command.

func ListDatabases Uses

func ListDatabases() *ListDatabasesOptions

ListDatabases creates a new *ListDatabasesOptions

func MergeListDatabasesOptions Uses

func MergeListDatabasesOptions(opts ...*ListDatabasesOptions) *ListDatabasesOptions

MergeListDatabasesOptions combines the given *ListDatabasesOptions into a single *ListDatabasesOptions in a last one wins fashion.

func (*ListDatabasesOptions) SetNameOnly Uses

func (ld *ListDatabasesOptions) SetNameOnly(b bool) *ListDatabasesOptions

SetNameOnly specifies whether to return only the database names.

type ListIndexesOptions Uses

type ListIndexesOptions struct {
    BatchSize *int32
    MaxTime   *time.Duration
}

ListIndexesOptions represents all possible options for the ListIndexes() function.

func ListIndexes Uses

func ListIndexes() *ListIndexesOptions

ListIndexes creates a new ListIndexesOptions instance.

func MergeListIndexesOptions Uses

func MergeListIndexesOptions(opts ...*ListIndexesOptions) *ListIndexesOptions

MergeListIndexesOptions combines the given *ListIndexesOptions into a single *ListIndexesOptions in a last one wins fashion.

func (*ListIndexesOptions) SetBatchSize Uses

func (l *ListIndexesOptions) SetBatchSize(i int32) *ListIndexesOptions

SetBatchSize specifies the number of documents to return in every batch.

func (*ListIndexesOptions) SetMaxTime Uses

func (l *ListIndexesOptions) SetMaxTime(d time.Duration) *ListIndexesOptions

SetMaxTime specifies the maximum amount of time to allow the query to run.

type MarshalError Uses

type MarshalError struct {
    Value interface{}
    Err   error
}

MarshalError is returned when attempting to transform a value into a document results in an error.

func (MarshalError) Error Uses

func (me MarshalError) Error() string

Error implements the error interface.

type NameOptions Uses

type NameOptions struct {
    Revision *int32 // Which revision (documents with the same filename and different uploadDate). Defaults to -1 (the most recent revision).
}

NameOptions represents all options that can be used for a GridFS download by name operation.

func GridFSName Uses

func GridFSName() *NameOptions

GridFSName creates a new *NameOptions

func MergeNameOptions Uses

func MergeNameOptions(opts ...*NameOptions) *NameOptions

MergeNameOptions combines the given *NameOptions into a single *NameOptions in a last one wins fashion.

func (*NameOptions) SetRevision Uses

func (n *NameOptions) SetRevision(r int32) *NameOptions

SetRevision specifies which revision of the file to retrieve. Defaults to -1. * Revision numbers are defined as follows: * 0 = the original stored file * 1 = the first revision * 2 = the second revision * etc… * -2 = the second most recent revision * -1 = the most recent revision

type ReplaceOptions Uses

type ReplaceOptions struct {
    BypassDocumentValidation *bool      // If true, allows the write to opt-out of document level validation
    Collation                *Collation // Specifies a collation
    Upsert                   *bool      // When true, creates a new document if no document matches the query
}

ReplaceOptions represents all possible options to the ReplaceOne() function.

func MergeReplaceOptions Uses

func MergeReplaceOptions(opts ...*ReplaceOptions) *ReplaceOptions

MergeReplaceOptions combines the argued ReplaceOptions into a single ReplaceOptions in a last-one-wins fashion

func Replace Uses

func Replace() *ReplaceOptions

Replace returns a pointer to a new ReplaceOptions

func (*ReplaceOptions) SetBypassDocumentValidation Uses

func (ro *ReplaceOptions) SetBypassDocumentValidation(b bool) *ReplaceOptions

SetBypassDocumentValidation allows the write to opt-out of document level validation. Valid for server versions >= 3.2. For servers < 3.2, this option is ignored.

func (*ReplaceOptions) SetCollation Uses

func (ro *ReplaceOptions) SetCollation(c *Collation) *ReplaceOptions

SetCollation specifies a collation. Valid for servers >= 3.4

func (*ReplaceOptions) SetUpsert Uses

func (ro *ReplaceOptions) SetUpsert(b bool) *ReplaceOptions

SetUpsert allows the creation of a new document if not document matches the query

type ReturnDocument Uses

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 RunCmdOptions Uses

type RunCmdOptions struct {
    ReadPreference *readpref.ReadPref // The read preference for the operation.
}

RunCmdOptions represents all possible options for a runCommand operation.

func MergeRunCmdOptions Uses

func MergeRunCmdOptions(opts ...*RunCmdOptions) *RunCmdOptions

MergeRunCmdOptions combines the given *RunCmdOptions into one *RunCmdOptions in a last one wins fashion.

func RunCmd Uses

func RunCmd() *RunCmdOptions

RunCmd creates a new *RunCmdOptions

func (*RunCmdOptions) SetReadPreference Uses

func (rc *RunCmdOptions) SetReadPreference(rp *readpref.ReadPref) *RunCmdOptions

SetReadPreference sets the read preference for the operation.

type SessionOptions Uses

type SessionOptions struct {
    CausalConsistency     *bool                      // Specifies if reads should be causally consistent. Defaults to true.
    DefaultReadConcern    *readconcern.ReadConcern   // The default read concern for transactions started in the session.
    DefaultReadPreference *readpref.ReadPref         // The default read preference for transactions started in the session.
    DefaultWriteConcern   *writeconcern.WriteConcern // The default write concern for transactions started in the session.
}

SessionOptions represents all possible options for creating a new session.

func MergeSessionOptions Uses

func MergeSessionOptions(opts ...*SessionOptions) *SessionOptions

MergeSessionOptions combines the given *SessionOptions into a single *SessionOptions in a last one wins fashion.

func Session Uses

func Session() *SessionOptions

Session creates a new *SessionOptions

func (*SessionOptions) SetCausalConsistency Uses

func (s *SessionOptions) SetCausalConsistency(b bool) *SessionOptions

SetCausalConsistency specifies if a session should be causally consistent. Defaults to true.

func (*SessionOptions) SetDefaultReadConcern Uses

func (s *SessionOptions) SetDefaultReadConcern(rc *readconcern.ReadConcern) *SessionOptions

SetDefaultReadConcern sets the default read concern for transactions started in a session.

func (*SessionOptions) SetDefaultReadPreference Uses

func (s *SessionOptions) SetDefaultReadPreference(rp *readpref.ReadPref) *SessionOptions

SetDefaultReadPreference sets the default read preference for transactions started in a session.

func (*SessionOptions) SetDefaultWriteConcern Uses

func (s *SessionOptions) SetDefaultWriteConcern(wc *writeconcern.WriteConcern) *SessionOptions

SetDefaultWriteConcern sets the default write concern for transactions started in a session.

type TransactionOptions Uses

type TransactionOptions struct {
    ReadConcern    *readconcern.ReadConcern   // The read concern for the transaction. Defaults to the session's read concern.
    ReadPreference *readpref.ReadPref         // The read preference for the transaction. Defaults to the session's read preference.
    WriteConcern   *writeconcern.WriteConcern // The write concern for the transaction. Defaults to the session's write concern.
}

TransactionOptions represents all possible options for starting a transaction.

func MergeTransactionOptions Uses

func MergeTransactionOptions(opts ...*TransactionOptions) *TransactionOptions

MergeTransactionOptions combines the given *TransactionOptions into a single *TransactionOptions in a last one wins fashion.

func Transaction Uses

func Transaction() *TransactionOptions

Transaction creates a new *TransactionOptions

func (*TransactionOptions) SetReadConcern Uses

func (t *TransactionOptions) SetReadConcern(rc *readconcern.ReadConcern) *TransactionOptions

SetReadConcern sets the read concern for the transaction.

func (*TransactionOptions) SetReadPreference Uses

func (t *TransactionOptions) SetReadPreference(rp *readpref.ReadPref) *TransactionOptions

SetReadPreference sets the read preference for the transaction.

func (*TransactionOptions) SetWriteConcern Uses

func (t *TransactionOptions) SetWriteConcern(wc *writeconcern.WriteConcern) *TransactionOptions

SetWriteConcern sets the write concern for the transaction.

type UpdateOptions Uses

type UpdateOptions struct {
    ArrayFilters             *ArrayFilters // A set of filters specifying to which array elements an update should apply
    BypassDocumentValidation *bool         // If true, allows the write to opt-out of document level validation
    Collation                *Collation    // Specifies a collation
    Upsert                   *bool         // When true, creates a new document if no document matches the query
}

UpdateOptions represents all possible options to the UpdateOne() and UpdateMany() functions.

func MergeUpdateOptions Uses

func MergeUpdateOptions(opts ...*UpdateOptions) *UpdateOptions

MergeUpdateOptions combines the argued UpdateOptions into a single UpdateOptions in a last-one-wins fashion

func Update Uses

func Update() *UpdateOptions

Update returns a pointer to a new UpdateOptions

func (*UpdateOptions) SetArrayFilters Uses

func (uo *UpdateOptions) SetArrayFilters(af ArrayFilters) *UpdateOptions

SetArrayFilters specifies a set of filters specifying to which array elements an update should apply Valid for server versions >= 3.6.

func (*UpdateOptions) SetBypassDocumentValidation Uses

func (uo *UpdateOptions) SetBypassDocumentValidation(b bool) *UpdateOptions

SetBypassDocumentValidation allows the write to opt-out of document level validation. Valid for server versions >= 3.2. For servers < 3.2, this option is ignored.

func (*UpdateOptions) SetCollation Uses

func (uo *UpdateOptions) SetCollation(c *Collation) *UpdateOptions

SetCollation specifies a collation. Valid for server versions >= 3.4.

func (*UpdateOptions) SetUpsert Uses

func (uo *UpdateOptions) SetUpsert(b bool) *UpdateOptions

SetUpsert allows the creation of a new document if not document matches the query

type UploadOptions Uses

type UploadOptions struct {
    ChunkSizeBytes *int32              // Chunk size in bytes. Defaults to the chunk size of the bucket.
    Metadata       interface{}         // User data for the 'metadata' field of the files collection document.
    Registry       *bsoncodec.Registry // The registry to use for converting filters. Defaults to bson.DefaultRegistry.
}

UploadOptions represents all possible options for a GridFS upload operation. If a registry is nil, bson.DefaultRegistry will be used when converting the Metadata interface to BSON.

func GridFSUpload Uses

func GridFSUpload() *UploadOptions

GridFSUpload creates a new *UploadOptions

func MergeUploadOptions Uses

func MergeUploadOptions(opts ...*UploadOptions) *UploadOptions

MergeUploadOptions combines the given *UploadOptions into a single *UploadOptions. If the chunk size is not set in any of the given *UploadOptions, the resulting *UploadOptions will have chunk size 255KB.

func (*UploadOptions) SetChunkSizeBytes Uses

func (u *UploadOptions) SetChunkSizeBytes(i int32) *UploadOptions

SetChunkSizeBytes sets the chunk size in bytes for the upload. Defaults to 255KB if not set.

func (*UploadOptions) SetMetadata Uses

func (u *UploadOptions) SetMetadata(doc interface{}) *UploadOptions

SetMetadata specfies the metadata for the upload.

Package options imports 22 packages (graph) and is imported by 16 packages. Updated 2019-03-20. Refresh now. Tools for package owners.