options

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2019 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultCausalConsistency = true

DefaultCausalConsistency is the default value for the CausalConsistency option.

View Source
var DefaultChunkSize int32 = 255 * 1024 // 255 KiB

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

View Source
var DefaultName = "fs"

DefaultName is the default name for a GridFS bucket.

View Source
var DefaultOrdered = true

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

View Source
var DefaultRevision int32 = -1

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

Functions

This section is empty.

Types

type AggregateOptions

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

func Aggregate() *AggregateOptions

Aggregate returns a pointer to a new AggregateOptions

func MergeAggregateOptions

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

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

func (*AggregateOptions) SetAllowDiskUse

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

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

SetBatchSize specifies the number of documents to return per batch

func (*AggregateOptions) SetBypassDocumentValidation

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

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

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

func (*AggregateOptions) SetComment

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

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

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

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

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

type ArrayFilters

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

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

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

type BucketOptions

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

func GridFSBucket() *BucketOptions

GridFSBucket creates a new *BucketOptions

func MergeBucketOptions

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

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

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

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

func (*BucketOptions) SetReadConcern

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

SetReadConcern sets the read concern for the bucket.

func (*BucketOptions) SetReadPreference

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

SetReadPreference sets the read preference for the bucket.

func (*BucketOptions) SetWriteConcern

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

SetWriteConcern sets the write concern for the bucket.

type BulkWriteOptions

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

func BulkWrite() *BulkWriteOptions

BulkWrite creates a new *BulkWriteOptions

func MergeBulkWriteOptions

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

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

func (*BulkWriteOptions) SetBypassDocumentValidation

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

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

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

func ChangeStream() *ChangeStreamOptions

ChangeStream returns a pointer to a new ChangeStreamOptions

func MergeChangeStreamOptions

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

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

func (*ChangeStreamOptions) SetBatchSize

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

SetBatchSize specifies the number of documents to return per batch

func (*ChangeStreamOptions) SetCollation

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

SetCollation specifies a collation

func (*ChangeStreamOptions) SetFullDocument

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

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

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

SetResumeAfter specifies the logical starting point for the new change stream

func (*ChangeStreamOptions) SetStartAtOperationTime

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

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

func Client() *ClientOptions

Client creates a new ClientOptions instance.

func MergeClientOptions

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

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

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

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

SetAuth sets the authentication options.

func (*ClientOptions) SetCompressors

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

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

func (*ClientOptions) SetConnectTimeout

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

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

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

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

SetHeartbeatInterval specifies the interval to wait between server monitoring checks.

func (*ClientOptions) SetHosts

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

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

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

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

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

func (*ClientOptions) SetMonitor

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

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

func (*ClientOptions) SetReadConcern

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

SetReadConcern specifies the read concern.

func (*ClientOptions) SetReadPreference

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

SetReadPreference specifies the read preference.

func (*ClientOptions) SetRegistry

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

SetRegistry specifies the bsoncodec.Registry.

func (*ClientOptions) SetReplicaSet

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

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

func (*ClientOptions) SetRetryWrites

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

SetRetryWrites specifies whether the client has retryable writes enabled.

func (*ClientOptions) SetServerSelectionTimeout

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

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

func (*ClientOptions) SetSocketTimeout

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

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

SetTLSConfig sets the tls.Config.

func (*ClientOptions) SetWriteConcern

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

SetWriteConcern sets the write concern.

func (*ClientOptions) SetZlibLevel

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

SetZlibLevel sets the level for the zlib compressor.

func (*ClientOptions) Validate

func (c *ClientOptions) 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 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

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

ToDocument converts the Collation to a bson.Raw.

type CollectionOptions

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

func Collection() *CollectionOptions

Collection creates a new CollectionOptions instance

func MergeCollectionOptions

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

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

func (*CollectionOptions) SetReadConcern

SetReadConcern sets the read concern for the collection.

func (*CollectionOptions) SetReadPreference

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

SetReadPreference sets the read preference for the collection.

func (*CollectionOptions) SetRegistry

SetRegistry sets the bsoncodec Registry for the collection.

func (*CollectionOptions) SetWriteConcern

SetWriteConcern sets the write concern for the collection.

type ContextDialer

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

ContextDialer makes new network connections

type CountOptions

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

func Count() *CountOptions

Count returns a pointer to a new CountOptions

func MergeCountOptions

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

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

func (*CountOptions) SetCollation

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

SetCollation specifies a collation Valid for server versions >= 3.4

func (*CountOptions) SetHint

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

SetHint specifies the index to use

func (*CountOptions) SetLimit

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

SetLimit specifies the maximum number of documents to count

func (*CountOptions) SetMaxTime

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

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

func (*CountOptions) SetSkip

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

SetSkip specifies the number of documents to skip before counting

type CreateIndexesOptions

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

func CreateIndexes() *CreateIndexesOptions

CreateIndexes creates a new CreateIndexesOptions instance.

func MergeCreateIndexesOptions

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

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

func (*CreateIndexesOptions) SetMaxTime

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

type Credential

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

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

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

func Database() *DatabaseOptions

Database creates a new DatabaseOptions instance

func MergeDatabaseOptions

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

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

func (*DatabaseOptions) SetReadConcern

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

SetReadConcern sets the read concern for the database.

func (*DatabaseOptions) SetReadPreference

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

SetReadPreference sets the read preference for the database.

func (*DatabaseOptions) SetRegistry

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

SetRegistry sets the bsoncodec Registry for the database.

func (*DatabaseOptions) SetWriteConcern

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

SetWriteConcern sets the write concern for the database.

type DeleteOptions

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

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

func Delete

func Delete() *DeleteOptions

Delete returns a pointer to a new DeleteOptions

func MergeDeleteOptions

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

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

func (*DeleteOptions) SetCollation

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

SetCollation specifies a collation Valid for servers >= 3.4.

type DistinctOptions

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

func Distinct() *DistinctOptions

Distinct returns a pointer to a new DistinctOptions

func MergeDistinctOptions

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

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

func (*DistinctOptions) SetCollation

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

SetCollation specifies a collation Valid for server versions >= 3.4

func (*DistinctOptions) SetMaxTime

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

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

type DropIndexesOptions

type DropIndexesOptions struct {
	MaxTime *time.Duration
}

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

func DropIndexes

func DropIndexes() *DropIndexesOptions

DropIndexes creates a new DropIndexesOptions instance.

func MergeDropIndexesOptions

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

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

func (*DropIndexesOptions) SetMaxTime

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

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

type EstimatedDocumentCountOptions

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

func EstimatedDocumentCount() *EstimatedDocumentCountOptions

EstimatedDocumentCount returns a pointer to a new EstimatedDocumentCountOptions

func MergeEstimatedDocumentCountOptions

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

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

func (*EstimatedDocumentCountOptions) SetMaxTime

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

type FindOneAndDeleteOptions

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

func FindOneAndDelete() *FindOneAndDeleteOptions

FindOneAndDelete creates a new FindOneAndDeleteOptions instance.

func MergeFindOneAndDeleteOptions

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

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

func (*FindOneAndDeleteOptions) SetCollation

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

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

func (*FindOneAndDeleteOptions) SetProjection

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

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

func (*FindOneAndDeleteOptions) SetSort

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

SetSort specifies the order in which to return documents.

type FindOneAndReplaceOptions

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

func FindOneAndReplace() *FindOneAndReplaceOptions

FindOneAndReplace creates a new FindOneAndReplaceOptions instance.

func MergeFindOneAndReplaceOptions

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

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

func (*FindOneAndReplaceOptions) SetBypassDocumentValidation

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

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

SetCollation specifies a Collation to use for the Find operation.

func (*FindOneAndReplaceOptions) SetMaxTime

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

func (*FindOneAndReplaceOptions) SetProjection

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

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

func (*FindOneAndReplaceOptions) SetReturnDocument

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

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

SetSort specifies the order in which to return documents.

func (*FindOneAndReplaceOptions) SetUpsert

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

type FindOneAndUpdateOptions

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

func FindOneAndUpdate() *FindOneAndUpdateOptions

FindOneAndUpdate creates a new FindOneAndUpdateOptions instance.

func MergeFindOneAndUpdateOptions

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

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

func (*FindOneAndUpdateOptions) SetArrayFilters

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

SetArrayFilters specifies a set of filters, which

func (*FindOneAndUpdateOptions) SetBypassDocumentValidation

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

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

func (*FindOneAndUpdateOptions) SetCollation

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

SetCollation specifies a Collation to use for the Find operation.

func (*FindOneAndUpdateOptions) SetMaxTime

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

func (*FindOneAndUpdateOptions) SetProjection

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

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

func (*FindOneAndUpdateOptions) SetReturnDocument

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

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

SetSort specifies the order in which to return documents.

func (*FindOneAndUpdateOptions) SetUpsert

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

type FindOneOptions

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

func FindOne() *FindOneOptions

FindOne creates a new FindOneOptions instance.

func MergeFindOneOptions

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

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

func (*FindOneOptions) SetAllowPartialResults

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

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

func (*FindOneOptions) SetBatchSize

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

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

func (*FindOneOptions) SetCollation

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

SetCollation specifies a Collation to use for the Find operation.

func (*FindOneOptions) SetComment

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

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

func (*FindOneOptions) SetCursorType

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

SetCursorType specifes the type of cursor to use.

func (*FindOneOptions) SetHint

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

SetHint specifies the index to use.

func (*FindOneOptions) SetMax

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

SetMax specifies an exclusive upper bound for a specific index.

func (*FindOneOptions) SetMaxAwaitTime

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

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

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

func (*FindOneOptions) SetMin

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

SetMin specifies the inclusive lower bound for a specific index.

func (*FindOneOptions) SetNoCursorTimeout

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

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

func (*FindOneOptions) SetOplogReplay

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

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

func (*FindOneOptions) SetProjection

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

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

func (*FindOneOptions) SetReturnKey

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

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

func (*FindOneOptions) SetShowRecordID

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

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

SetSkip specifies the number of documents to skip before returning.

func (*FindOneOptions) SetSnapshot

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

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

SetSort specifies the order in which to return documents.

type FindOptions

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

func Find() *FindOptions

Find creates a new FindOptions instance.

func MergeFindOptions

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

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

func (*FindOptions) SetAllowPartialResults

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

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

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

func (*FindOptions) SetCollation

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

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

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

func (*FindOptions) SetCursorType

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

SetCursorType specifes the type of cursor to use.

func (*FindOptions) SetHint

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

SetHint specifies the index to use.

func (*FindOptions) SetLimit

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

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

SetMax specifies an exclusive upper bound for a specific index.

func (*FindOptions) SetMaxAwaitTime

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

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

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

func (*FindOptions) SetMin

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

SetMin specifies the inclusive lower bound for a specific index.

func (*FindOptions) SetNoCursorTimeout

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

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

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

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

func (*FindOptions) SetReturnKey

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

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

func (*FindOptions) SetShowRecordID

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

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

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

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

SetSort specifies the order in which to return documents.

type FullDocument

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

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

func GridFSFind() *GridFSFindOptions

GridFSFind creates a new GridFSFindOptions instance.

func MergeGridFSFindOptions

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

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

func (*GridFSFindOptions) SetBatchSize

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

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

func (*GridFSFindOptions) SetLimit

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

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

func (*GridFSFindOptions) SetNoCursorTimeout

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

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

func (*GridFSFindOptions) SetSkip

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

SetSkip specifies the number of documents to skip before returning.

func (*GridFSFindOptions) SetSort

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

SetSort specifies the order in which to return documents.

type IndexOptions

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

func Index() *IndexOptions

Index creates a new *IndexOptions

func MergeIndexOptions

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

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

func (*IndexOptions) SetBackground

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

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

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

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

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

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

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

func (*IndexOptions) SetLanguageOverride

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

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

func (*IndexOptions) SetMax

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

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

func (*IndexOptions) SetMin

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

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

func (*IndexOptions) SetName

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

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

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

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

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

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

func (*IndexOptions) SetTextVersion

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

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

SetUnique forces the index to be unique.

func (*IndexOptions) SetVersion

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

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

func (*IndexOptions) SetWeights

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

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

type InsertManyOptions

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

func InsertMany() *InsertManyOptions

InsertMany returns a pointer to a new InsertManyOptions

func MergeInsertManyOptions

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

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

func (*InsertManyOptions) SetBypassDocumentValidation

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

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

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

func InsertOne() *InsertOneOptions

InsertOne returns a pointer to a new InsertOneOptions

func MergeInsertOneOptions

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

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

func (*InsertOneOptions) SetBypassDocumentValidation

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

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

func ListCollections() *ListCollectionsOptions

ListCollections creates a new *ListCollectionsOptions

func MergeListCollectionsOptions

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

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

func (*ListCollectionsOptions) SetNameOnly

SetNameOnly specifies whether to return only the collection names.

type ListDatabasesOptions

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

func ListDatabases() *ListDatabasesOptions

ListDatabases creates a new *ListDatabasesOptions

func MergeListDatabasesOptions

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

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

func (*ListDatabasesOptions) SetNameOnly

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

SetNameOnly specifies whether to return only the database names.

type ListIndexesOptions

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

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

func ListIndexes

func ListIndexes() *ListIndexesOptions

ListIndexes creates a new ListIndexesOptions instance.

func MergeListIndexesOptions

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

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

func (*ListIndexesOptions) SetBatchSize

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

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

func (*ListIndexesOptions) SetMaxTime

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

type MarshalError

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

func (me MarshalError) Error() string

Error implements the error interface.

type NameOptions

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

func GridFSName() *NameOptions

GridFSName creates a new *NameOptions

func MergeNameOptions

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

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

func (*NameOptions) SetRevision

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

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

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

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

func Replace

func Replace() *ReplaceOptions

Replace returns a pointer to a new ReplaceOptions

func (*ReplaceOptions) SetBypassDocumentValidation

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

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

SetCollation specifies a collation. Valid for servers >= 3.4

func (*ReplaceOptions) SetUpsert

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

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

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 RunCmdOptions

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

RunCmdOptions represents all possible options for a runCommand operation.

func MergeRunCmdOptions

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

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

func RunCmd

func RunCmd() *RunCmdOptions

RunCmd creates a new *RunCmdOptions

func (*RunCmdOptions) SetReadPreference

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

SetReadPreference sets the read preference for the operation.

type SessionOptions

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

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

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

func Session

func Session() *SessionOptions

Session creates a new *SessionOptions

func (*SessionOptions) SetCausalConsistency

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

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

func (*SessionOptions) SetDefaultReadConcern

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

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

func (*SessionOptions) SetDefaultReadPreference

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

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

func (*SessionOptions) SetDefaultWriteConcern

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

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

type TransactionOptions

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

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

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

func Transaction

func Transaction() *TransactionOptions

Transaction creates a new *TransactionOptions

func (*TransactionOptions) SetReadConcern

SetReadConcern sets the read concern for the transaction.

func (*TransactionOptions) SetReadPreference

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

SetReadPreference sets the read preference for the transaction.

func (*TransactionOptions) SetWriteConcern

SetWriteConcern sets the write concern for the transaction.

type UpdateOptions

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

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

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

func Update

func Update() *UpdateOptions

Update returns a pointer to a new UpdateOptions

func (*UpdateOptions) SetArrayFilters

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

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

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

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

func (*UpdateOptions) SetUpsert

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

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

type UploadOptions

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

func GridFSUpload() *UploadOptions

GridFSUpload creates a new *UploadOptions

func MergeUploadOptions

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

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

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

SetMetadata specfies the metadata for the upload.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL