options

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2018 License: Apache-2.0 Imports: 15 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 * 1000

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

SetCollations 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

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() (bsonx.Arr, error)

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  bsonx.Doc      // Specifies the logical starting point for the new change stream
}

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(d bsonx.Doc) *ChangeStreamOptions

SetResumeAfter specifies the logical starting point for the new change stream

type ClientOptions

type ClientOptions struct {
	TopologyOptions []topology.Option
	ConnString      connstring.ConnString
	RetryWrites     *bool
	ReadPreference  *readpref.ReadPref
	ReadConcern     *readconcern.ReadConcern
	WriteConcern    *writeconcern.WriteConcern
	Registry        *bsoncodec.Registry
}

ClientOptions represents all possbile options to configure a client.

func Client

func Client() *ClientOptions

Client creates a new ClientOptions instance.

func MergeClientOptions

func MergeClientOptions(cs connstring.ConnString, 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) 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) 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.

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) SetMaxConnsPerHost

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

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

func (*ClientOptions) SetMaxIdleConnsPerHost

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

SetMaxIdleConnsPerHost specifies the number of connections in a server's connection pool that can be idle at any given time.

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) SetRegistery

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

func (c *ClientOptions) SetSSL(ssl *SSLOpt) *ClientOptions

SetSSL sets SSL options.

func (*ClientOptions) SetServerSelectionTimeout

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

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

func (*ClientOptions) SetSingle

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

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

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) SetWriteConcern

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

SetWriteConcern sets the write concern.

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"
	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() bsonx.Doc

ToDocument converts the Collation to a *bsonx.Document

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   *int64      // 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(i int64) *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 create() function.

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
}

Credential holds auth options.

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

AuthMechanismProperties specifies additional configuration options which may be used by certain authentication mechanisms.

AuthSource specifies the database to authenticate against.

Username specifies the username that will be authenticated.

Password specifies the password used for authentication.

type 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   *int64     // 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(i int64) *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 create() 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 *int64 // 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 findOne() 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 findOne() 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 findOne() 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

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

func (*FindOneAndUpdateOptions) SetBypassDocumentValidation

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

SetArrayFilters specifies a set of filters, which

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.

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 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()

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()

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 create() 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

BatchSize 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 SSLOpt

type SSLOpt struct {
	Enabled                      bool
	ClientCertificateKeyFile     string
	ClientCertificateKeyPassword func() string
	Insecure                     bool
	CaFile                       string
}

SSLOpt holds client SSL options.

Enabled indicates whether SSL should be enabled.

ClientCertificateKeyFile specifies the file containing the client certificate and private key used for authentication.

ClientCertificateKeyPassword provides a callback that returns a password used for decrypting the private key of a PEM file (if one is provided).

Insecure indicates whether to skip the verification of the server certificate and hostname.

CaFile specifies the file containing the certificate authority used for SSL connections.

type 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       bsonx.Doc // User data for the 'metadata' field of the files collection document.
}

UploadOptions represents all possible options for a GridFS upload operation.

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 bsonx.Doc) *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