options

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2019 License: Apache-2.0 Imports: 23 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 added in v0.1.0

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 added in v0.1.0

func Aggregate() *AggregateOptions

Aggregate returns a pointer to a new AggregateOptions

func MergeAggregateOptions added in v0.1.0

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

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

func (*AggregateOptions) SetAllowDiskUse added in v0.1.0

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 added in v0.1.0

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

SetBatchSize specifies the number of documents to return per batch

func (*AggregateOptions) SetBypassDocumentValidation added in v0.1.0

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 added in v0.1.0

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

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

func (*AggregateOptions) SetComment added in v0.1.0

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 added in v0.1.0

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 added in v0.1.0

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 added in v0.1.0

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

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

type ArrayFilters added in v0.1.0

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 added in v0.1.0

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

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

func (*ArrayFilters) ToArrayDocument added in v1.1.0

func (af *ArrayFilters) ToArrayDocument() (bson.Raw, error)

ToArrayDocument builds a BSON array for the array filters CRUD option. If the registry for af is nil, bson.DefaultRegistry will be used when converting the filter interfaces to BSON.

type BucketOptions added in v0.1.0

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 added in v0.1.0

func GridFSBucket() *BucketOptions

GridFSBucket creates a new *BucketOptions

func MergeBucketOptions added in v0.1.0

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 added in v0.1.0

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 added in v0.1.0

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

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

func (*BucketOptions) SetReadConcern added in v0.1.0

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

SetReadConcern sets the read concern for the bucket.

func (*BucketOptions) SetReadPreference added in v0.1.0

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

SetReadPreference sets the read preference for the bucket.

func (*BucketOptions) SetWriteConcern added in v0.1.0

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

SetWriteConcern sets the write concern for the bucket.

type BulkWriteOptions added in v0.1.0

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 added in v0.1.0

func BulkWrite() *BulkWriteOptions

BulkWrite creates a new *BulkWriteOptions

func MergeBulkWriteOptions added in v0.1.0

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

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

func (*BulkWriteOptions) SetBypassDocumentValidation added in v0.1.0

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 added in v0.1.0

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 added in v0.1.0

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.
	StartAfter           interface{}          // Specifies a resume token. The started change stream will return the first notification after the token.
}

ChangeStreamOptions represents all possible options to a change stream

func ChangeStream added in v0.1.0

func ChangeStream() *ChangeStreamOptions

ChangeStream returns a pointer to a new ChangeStreamOptions

func MergeChangeStreamOptions added in v0.1.0

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

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

func (*ChangeStreamOptions) SetBatchSize added in v0.1.0

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

SetBatchSize specifies the number of documents to return per batch

func (*ChangeStreamOptions) SetCollation added in v0.1.0

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

SetCollation specifies a collation

func (*ChangeStreamOptions) SetFullDocument added in v0.1.0

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 added in v0.1.0

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 added in v0.1.0

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

SetResumeAfter specifies the logical starting point for the new change stream

func (*ChangeStreamOptions) SetStartAfter added in v1.1.0

func (cso *ChangeStreamOptions) SetStartAfter(sa interface{}) *ChangeStreamOptions

SetStartAfter specifies a resume token. The resulting change stream will return the first notification after the token. Cannot be used in conjunction with ResumeAfter.

func (*ChangeStreamOptions) SetStartAtOperationTime added in v0.1.0

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 added in v0.1.0

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            *uint64
	MinPoolSize            *uint64
	PoolMonitor            *event.PoolMonitor
	Monitor                *event.CommandMonitor
	ReadConcern            *readconcern.ReadConcern
	ReadPreference         *readpref.ReadPref
	Registry               *bsoncodec.Registry
	ReplicaSet             *string
	RetryWrites            *bool
	RetryReads             *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 added in v0.1.0

func Client() *ClientOptions

Client creates a new ClientOptions instance.

func MergeClientOptions added in v0.1.0

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 added in v1.0.0

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 added in v0.1.0

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 added in v0.1.0

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

SetAuth sets the authentication options.

func (*ClientOptions) SetCompressors added in v1.0.0

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

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

func (*ClientOptions) SetConnectTimeout added in v0.1.0

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 added in v0.1.0

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 added in v1.0.0

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 added in v0.1.0

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

SetHeartbeatInterval specifies the interval to wait between server monitoring checks.

func (*ClientOptions) SetHosts added in v0.1.0

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 added in v0.1.0

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 added in v0.1.0

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 added in v0.1.0

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

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

func (*ClientOptions) SetMinPoolSize added in v1.1.0

func (c *ClientOptions) SetMinPoolSize(u uint64) *ClientOptions

SetMinPoolSize specifies the min size of a server's connection pool.

func (*ClientOptions) SetMonitor added in v0.1.0

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

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

func (*ClientOptions) SetPoolMonitor added in v1.1.0

func (c *ClientOptions) SetPoolMonitor(m *event.PoolMonitor) *ClientOptions

SetPoolMonitor specifies the PoolMonitor for a server's connection pool.

func (*ClientOptions) SetReadConcern added in v0.1.0

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

SetReadConcern specifies the read concern.

func (*ClientOptions) SetReadPreference added in v0.1.0

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

SetReadPreference specifies the read preference.

func (*ClientOptions) SetRegistry added in v0.1.0

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

SetRegistry specifies the bsoncodec.Registry.

func (*ClientOptions) SetReplicaSet added in v0.1.0

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

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

func (*ClientOptions) SetRetryWrites added in v0.1.0

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

SetRetryWrites specifies whether the client has retryable writes enabled.

func (*ClientOptions) SetServerSelectionTimeout added in v0.1.0

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

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

func (*ClientOptions) SetSocketTimeout added in v0.1.0

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 added in v1.0.0

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

SetTLSConfig sets the tls.Config.

func (*ClientOptions) SetWriteConcern added in v0.1.0

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

SetWriteConcern sets the write concern.

func (*ClientOptions) SetZlibLevel added in v1.0.0

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

SetZlibLevel sets the level for the zlib compressor.

func (*ClientOptions) Validate added in v1.0.0

func (c *ClientOptions) Validate() error

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

type Collation added in v0.1.0

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 added in v0.1.0

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

ToDocument converts the Collation to a bson.Raw.

type CollectionOptions added in v0.1.0

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 added in v0.1.0

func Collection() *CollectionOptions

Collection creates a new CollectionOptions instance

func MergeCollectionOptions added in v0.1.0

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

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

func (*CollectionOptions) SetReadConcern added in v0.1.0

SetReadConcern sets the read concern for the collection.

func (*CollectionOptions) SetReadPreference added in v0.1.0

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

SetReadPreference sets the read preference for the collection.

func (*CollectionOptions) SetRegistry added in v0.1.0

SetRegistry sets the bsoncodec Registry for the collection.

func (*CollectionOptions) SetWriteConcern added in v0.1.0

SetWriteConcern sets the write concern for the collection.

type ContextDialer added in v0.1.0

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

ContextDialer makes new network connections

type CountOptions added in v0.1.0

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 added in v0.1.0

func Count() *CountOptions

Count returns a pointer to a new CountOptions

func MergeCountOptions added in v0.1.0

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

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

func (*CountOptions) SetCollation added in v0.1.0

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

SetCollation specifies a collation Valid for server versions >= 3.4

func (*CountOptions) SetHint added in v0.1.0

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

SetHint specifies the index to use

func (*CountOptions) SetLimit added in v0.1.0

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

SetLimit specifies the maximum number of documents to count

func (*CountOptions) SetMaxTime added in v0.1.0

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

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

func (*CountOptions) SetSkip added in v0.1.0

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

SetSkip specifies the number of documents to skip before counting

type CreateIndexesOptions added in v0.1.0

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 added in v0.1.0

func CreateIndexes() *CreateIndexesOptions

CreateIndexes creates a new CreateIndexesOptions instance.

func MergeCreateIndexesOptions added in v0.1.0

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

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

func (*CreateIndexesOptions) SetMaxTime added in v0.1.0

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

type Credential added in v0.1.0

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 added in v0.1.0

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 added in v0.1.0

func Database() *DatabaseOptions

Database creates a new DatabaseOptions instance

func MergeDatabaseOptions added in v0.1.0

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

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

func (*DatabaseOptions) SetReadConcern added in v0.1.0

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

SetReadConcern sets the read concern for the database.

func (*DatabaseOptions) SetReadPreference added in v0.1.0

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

SetReadPreference sets the read preference for the database.

func (*DatabaseOptions) SetRegistry added in v0.1.0

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

SetRegistry sets the bsoncodec Registry for the database.

func (*DatabaseOptions) SetWriteConcern added in v0.1.0

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

SetWriteConcern sets the write concern for the database.

type DeleteOptions added in v0.1.0

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

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

func Delete added in v0.1.0

func Delete() *DeleteOptions

Delete returns a pointer to a new DeleteOptions

func MergeDeleteOptions added in v0.1.0

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

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

func (*DeleteOptions) SetCollation added in v0.1.0

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

SetCollation specifies a collation Valid for servers >= 3.4.

type DistinctOptions added in v0.1.0

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 added in v0.1.0

func Distinct() *DistinctOptions

Distinct returns a pointer to a new DistinctOptions

func MergeDistinctOptions added in v0.1.0

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

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

func (*DistinctOptions) SetCollation added in v0.1.0

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

SetCollation specifies a collation Valid for server versions >= 3.4

func (*DistinctOptions) SetMaxTime added in v0.1.0

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

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

type DropIndexesOptions added in v0.1.0

type DropIndexesOptions struct {
	MaxTime *time.Duration
}

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

func DropIndexes added in v0.1.0

func DropIndexes() *DropIndexesOptions

DropIndexes creates a new DropIndexesOptions instance.

func MergeDropIndexesOptions added in v0.1.0

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

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

func (*DropIndexesOptions) SetMaxTime added in v0.1.0

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

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

type EstimatedDocumentCountOptions added in v0.1.0

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 added in v0.1.0

func EstimatedDocumentCount() *EstimatedDocumentCountOptions

EstimatedDocumentCount returns a pointer to a new EstimatedDocumentCountOptions

func MergeEstimatedDocumentCountOptions added in v0.1.0

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

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

func (*EstimatedDocumentCountOptions) SetMaxTime added in v0.1.0

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

type FindOneAndDeleteOptions added in v0.1.0

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 added in v0.1.0

func FindOneAndDelete() *FindOneAndDeleteOptions

FindOneAndDelete creates a new FindOneAndDeleteOptions instance.

func MergeFindOneAndDeleteOptions added in v0.1.0

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

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

func (*FindOneAndDeleteOptions) SetCollation added in v0.1.0

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 added in v0.1.0

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

func (*FindOneAndDeleteOptions) SetProjection added in v0.1.0

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

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

func (*FindOneAndDeleteOptions) SetSort added in v0.1.0

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

SetSort specifies the order in which to return documents.

type FindOneAndReplaceOptions added in v0.1.0

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 added in v0.1.0

func FindOneAndReplace() *FindOneAndReplaceOptions

FindOneAndReplace creates a new FindOneAndReplaceOptions instance.

func MergeFindOneAndReplaceOptions added in v0.1.0

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

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

func (*FindOneAndReplaceOptions) SetBypassDocumentValidation added in v0.1.0

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 added in v0.1.0

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

SetCollation specifies a Collation to use for the Find operation.

func (*FindOneAndReplaceOptions) SetMaxTime added in v0.1.0

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

func (*FindOneAndReplaceOptions) SetProjection added in v0.1.0

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

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

func (*FindOneAndReplaceOptions) SetReturnDocument added in v0.1.0

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 added in v0.1.0

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

SetSort specifies the order in which to return documents.

func (*FindOneAndReplaceOptions) SetUpsert added in v0.1.0

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

type FindOneAndUpdateOptions added in v0.1.0

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 added in v0.1.0

func FindOneAndUpdate() *FindOneAndUpdateOptions

FindOneAndUpdate creates a new FindOneAndUpdateOptions instance.

func MergeFindOneAndUpdateOptions added in v0.1.0

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

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

func (*FindOneAndUpdateOptions) SetArrayFilters added in v0.1.0

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

SetArrayFilters specifies a set of filters, which

func (*FindOneAndUpdateOptions) SetBypassDocumentValidation added in v0.1.0

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

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

func (*FindOneAndUpdateOptions) SetCollation added in v0.1.0

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

SetCollation specifies a Collation to use for the Find operation.

func (*FindOneAndUpdateOptions) SetMaxTime added in v0.1.0

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

func (*FindOneAndUpdateOptions) SetProjection added in v0.1.0

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

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

func (*FindOneAndUpdateOptions) SetReturnDocument added in v0.1.0

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 added in v0.1.0

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

SetSort specifies the order in which to return documents.

func (*FindOneAndUpdateOptions) SetUpsert added in v0.1.0

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

type FindOneOptions added in v0.1.0

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 added in v0.1.0

func FindOne() *FindOneOptions

FindOne creates a new FindOneOptions instance.

func MergeFindOneOptions added in v0.1.0

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

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

func (*FindOneOptions) SetAllowPartialResults added in v0.1.0

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

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

func (*FindOneOptions) SetBatchSize added in v0.1.0

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

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

func (*FindOneOptions) SetCollation added in v0.1.0

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

SetCollation specifies a Collation to use for the Find operation.

func (*FindOneOptions) SetComment added in v0.1.0

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

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

func (*FindOneOptions) SetCursorType added in v0.1.0

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

SetCursorType specifes the type of cursor to use.

func (*FindOneOptions) SetHint added in v0.1.0

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

SetHint specifies the index to use.

func (*FindOneOptions) SetMax added in v0.1.0

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

SetMax specifies an exclusive upper bound for a specific index.

func (*FindOneOptions) SetMaxAwaitTime added in v0.1.0

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 added in v0.1.0

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

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

func (*FindOneOptions) SetMin added in v0.1.0

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

SetMin specifies the inclusive lower bound for a specific index.

func (*FindOneOptions) SetNoCursorTimeout added in v0.1.0

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

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

func (*FindOneOptions) SetOplogReplay added in v0.1.0

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

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

func (*FindOneOptions) SetProjection added in v0.1.0

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

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

func (*FindOneOptions) SetReturnKey added in v0.1.0

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

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

func (*FindOneOptions) SetShowRecordID added in v0.1.0

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 added in v0.1.0

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

SetSkip specifies the number of documents to skip before returning.

func (*FindOneOptions) SetSnapshot added in v0.1.0

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 added in v0.1.0

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

SetSort specifies the order in which to return documents.

type FindOptions added in v0.1.0

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 added in v0.1.0

func Find() *FindOptions

Find creates a new FindOptions instance.

func MergeFindOptions added in v0.1.0

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

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

func (*FindOptions) SetAllowPartialResults added in v0.1.0

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 added in v0.1.0

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

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

func (*FindOptions) SetCollation added in v0.1.0

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 added in v0.1.0

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

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

func (*FindOptions) SetCursorType added in v0.1.0

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

SetCursorType specifes the type of cursor to use.

func (*FindOptions) SetHint added in v0.1.0

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

SetHint specifies the index to use.

func (*FindOptions) SetLimit added in v0.1.0

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 added in v0.1.0

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

SetMax specifies an exclusive upper bound for a specific index.

func (*FindOptions) SetMaxAwaitTime added in v0.1.0

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 added in v0.1.0

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

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

func (*FindOptions) SetMin added in v0.1.0

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

SetMin specifies the inclusive lower bound for a specific index.

func (*FindOptions) SetNoCursorTimeout added in v0.1.0

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 added in v0.1.0

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 added in v0.1.0

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

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

func (*FindOptions) SetReturnKey added in v0.1.0

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

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

func (*FindOptions) SetShowRecordID added in v0.1.0

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 added in v0.1.0

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 added in v0.1.0

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 added in v0.1.0

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

SetSort specifies the order in which to return documents.

type FullDocument added in v0.1.0

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 added in v0.1.0

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 added in v0.1.0

func GridFSFind() *GridFSFindOptions

GridFSFind creates a new GridFSFindOptions instance.

func MergeGridFSFindOptions added in v0.1.0

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

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

func (*GridFSFindOptions) SetBatchSize added in v0.1.0

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

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

func (*GridFSFindOptions) SetLimit added in v0.1.0

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 added in v0.1.0

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

func (*GridFSFindOptions) SetNoCursorTimeout added in v0.1.0

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

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

func (*GridFSFindOptions) SetSkip added in v0.1.0

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

SetSkip specifies the number of documents to skip before returning.

func (*GridFSFindOptions) SetSort added in v0.1.0

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

SetSort specifies the order in which to return documents.

type IndexOptions added in v0.2.0

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
	WildcardProjection      interface{}
}

IndexOptions represents all possible options to configure a new index.

func Index added in v0.2.0

func Index() *IndexOptions

Index creates a new *IndexOptions

func MergeIndexOptions added in v0.2.0

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

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

func (*IndexOptions) SetBackground added in v0.2.0

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 added in v0.2.0

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 added in v0.2.0

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 added in v0.2.0

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 added in v0.2.0

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 added in v0.2.0

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

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

func (*IndexOptions) SetLanguageOverride added in v0.2.0

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

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

func (*IndexOptions) SetMax added in v0.2.0

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

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

func (*IndexOptions) SetMin added in v0.2.0

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

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

func (*IndexOptions) SetName added in v0.2.0

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 added in v0.2.0

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 added in v0.2.0

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 added in v0.2.0

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 added in v0.2.0

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

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

func (*IndexOptions) SetTextVersion added in v0.2.0

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 added in v0.2.0

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

SetUnique forces the index to be unique.

func (*IndexOptions) SetVersion added in v0.2.0

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

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

func (*IndexOptions) SetWeights added in v0.2.0

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

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

func (*IndexOptions) SetWildcardProjection added in v1.1.0

func (i *IndexOptions) SetWildcardProjection(wildcardProjection interface{}) *IndexOptions

SetWildcardProjection specifies a wildcard projection for a wildcard index.

type InsertManyOptions added in v0.1.0

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 added in v0.1.0

func InsertMany() *InsertManyOptions

InsertMany returns a pointer to a new InsertManyOptions

func MergeInsertManyOptions added in v0.1.0

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

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

func (*InsertManyOptions) SetBypassDocumentValidation added in v0.1.0

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 added in v0.1.0

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 added in v0.1.0

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 added in v0.1.0

func InsertOne() *InsertOneOptions

InsertOne returns a pointer to a new InsertOneOptions

func MergeInsertOneOptions added in v0.1.0

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

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

func (*InsertOneOptions) SetBypassDocumentValidation added in v0.1.0

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 added in v0.1.0

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 added in v0.1.0

func ListCollections() *ListCollectionsOptions

ListCollections creates a new *ListCollectionsOptions

func MergeListCollectionsOptions added in v0.1.0

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

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

func (*ListCollectionsOptions) SetNameOnly added in v0.1.0

SetNameOnly specifies whether to return only the collection names.

type ListDatabasesOptions added in v0.1.0

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 added in v0.1.0

func ListDatabases() *ListDatabasesOptions

ListDatabases creates a new *ListDatabasesOptions

func MergeListDatabasesOptions added in v0.1.0

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

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

func (*ListDatabasesOptions) SetNameOnly added in v0.1.0

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

SetNameOnly specifies whether to return only the database names.

type ListIndexesOptions added in v0.1.0

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

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

func ListIndexes added in v0.1.0

func ListIndexes() *ListIndexesOptions

ListIndexes creates a new ListIndexesOptions instance.

func MergeListIndexesOptions added in v0.1.0

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

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

func (*ListIndexesOptions) SetBatchSize added in v0.1.0

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

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

func (*ListIndexesOptions) SetMaxTime added in v0.1.0

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

type MarshalError added in v0.1.0

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 added in v0.1.0

func (me MarshalError) Error() string

Error implements the error interface.

type NameOptions added in v0.1.0

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 added in v0.1.0

func GridFSName() *NameOptions

GridFSName creates a new *NameOptions

func MergeNameOptions added in v0.1.0

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

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

func (*NameOptions) SetRevision added in v0.1.0

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 added in v0.1.0

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 added in v0.1.0

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

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

func Replace added in v0.1.0

func Replace() *ReplaceOptions

Replace returns a pointer to a new ReplaceOptions

func (*ReplaceOptions) SetBypassDocumentValidation added in v0.1.0

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 added in v0.1.0

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

SetCollation specifies a collation. Valid for servers >= 3.4

func (*ReplaceOptions) SetUpsert added in v0.1.0

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 added in v0.1.0

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

RunCmdOptions represents all possible options for a runCommand operation.

func MergeRunCmdOptions added in v0.1.0

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

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

func RunCmd added in v0.1.0

func RunCmd() *RunCmdOptions

RunCmd creates a new *RunCmdOptions

func (*RunCmdOptions) SetReadPreference added in v0.1.0

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

SetReadPreference sets the read preference for the operation.

type SessionOptions added in v0.1.0

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.
	DefaultMaxCommitTime  *time.Duration             // The default max commit time for transactions started in the session.
}

SessionOptions represents all possible options for creating a new session.

func MergeSessionOptions added in v0.1.0

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

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

func Session added in v0.1.0

func Session() *SessionOptions

Session creates a new *SessionOptions

func (*SessionOptions) SetCausalConsistency added in v0.1.0

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

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

func (*SessionOptions) SetDefaultMaxCommitTime added in v1.1.0

func (s *SessionOptions) SetDefaultMaxCommitTime(mct *time.Duration) *SessionOptions

SetDefaultMaxCommitTime sets the default max commit time for transactions started in a session.

func (*SessionOptions) SetDefaultReadConcern added in v0.1.0

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

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

func (*SessionOptions) SetDefaultReadPreference added in v0.1.0

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

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

func (*SessionOptions) SetDefaultWriteConcern added in v0.1.0

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

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

type TransactionOptions added in v0.1.0

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.
	MaxCommitTime  *time.Duration             // The maximum amount of time to allow a single commitTransaction command to run.
}

TransactionOptions represents all possible options for starting a transaction.

func MergeTransactionOptions added in v0.1.0

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

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

func Transaction added in v0.1.0

func Transaction() *TransactionOptions

Transaction creates a new *TransactionOptions

func (*TransactionOptions) SetMaxCommitTime added in v1.1.0

func (t *TransactionOptions) SetMaxCommitTime(mct *time.Duration) *TransactionOptions

SetMaxCommitTime sets the max commit time for the transaction.

func (*TransactionOptions) SetReadConcern added in v0.1.0

SetReadConcern sets the read concern for the transaction.

func (*TransactionOptions) SetReadPreference added in v0.1.0

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

SetReadPreference sets the read preference for the transaction.

func (*TransactionOptions) SetWriteConcern added in v0.1.0

SetWriteConcern sets the write concern for the transaction.

type UpdateOptions added in v0.1.0

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 added in v0.1.0

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

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

func Update added in v0.1.0

func Update() *UpdateOptions

Update returns a pointer to a new UpdateOptions

func (*UpdateOptions) SetArrayFilters added in v0.1.0

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 added in v0.1.0

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 added in v0.1.0

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

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

func (*UpdateOptions) SetUpsert added in v0.1.0

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

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

type UploadOptions added in v0.1.0

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 added in v0.1.0

func GridFSUpload() *UploadOptions

GridFSUpload creates a new *UploadOptions

func MergeUploadOptions added in v0.1.0

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 added in v0.1.0

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 added in v0.1.0

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