option

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseArrayFiltersMongoOptions

func ParseArrayFiltersMongoOptions(a *ArrayFilters) *options.ArrayFilters

ParseArrayFiltersMongoOptions convert ArrayFilters to mongo options.ArrayFilters

func ParseCollationMongoOptions

func ParseCollationMongoOptions(c *Collation) *options.Collation

ParseCollationMongoOptions convert Collation to mongo options.Collation

func ParseCursorType

func ParseCursorType(c *CursorType) *options.CursorType

ParseCursorType convert CursorType to mongo options.CursorType

func ParseFullDocument

func ParseFullDocument(f *FullDocument) *options.FullDocument

ParseFullDocument convert FullDocument to mongo options.FullDocument

func ParseReturnDocument

func ParseReturnDocument(r *ReturnDocument) *options.ReturnDocument

ParseReturnDocument convert ReturnDocument to mongo options.ReturnDocument

Types

type Aggregate

type Aggregate struct {
	// AllowDiskUse If true, the operation can write to temporary files in the _tmp subdirectory of the database
	// directory path on the server. The default value is false.
	AllowDiskUse *bool
	// BatchSize
	// The maximum number of documents to be included in each batch returned by the server.
	BatchSize *int32
	// BypassDocumentValidation If true, writes executed as part of the operation will opt out of document-level
	// validation on the server. This option is valid for MongoDB versions >= 3.2 and is ignored for previous server
	// versions. The default value is false. See https://www.mongodb.com/docs/manual/core/schema-validation/ for more
	// information about document validation.
	BypassDocumentValidation *bool
	// Collation Specifies a collation to use for string comparisons during the operation. This option is only
	// valid for MongoDB versions >= 3.4. For previous server versions, the driver will return an error if this option
	// is used. The default value is nil, which means the default collation of the collection will be used.
	Collation *Collation
	// MaxTime The maximum amount of time that the query can run on the server. The default value is nil, meaning that
	// there is no time limit for query execution.
	//
	// NOTE: MaxTime will be deprecated in a future release. The more general Timeout option may be used in
	// its place to control the amount of time that a single operation can run before returning an error. MaxTime is
	// ignored if Timeout is set on the client.
	MaxTime *time.Duration
	// MaxAwaitTime The maximum amount of time that the server should wait for new documents to satisfy a cursor query.
	// This option is only valid for MongoDB versions >= 3.2 and is ignored for previous server versions.
	MaxAwaitTime *time.Duration
	// Comment A string that will be included in server logs, profiling logs, and currentOp queries to help trace the
	// operation. The default is nil, which means that no comment will be included in the logs.
	Comment *string
	// Hint The index to use for the aggregation. This should either be the index name as a string or the index
	// specification as a document. The hint does not apply to $lookup and $graphLookup aggregation stages. The driver
	// will return an error if the hint parameter is a multi-key map. The default value is nil, which means that no hint
	// will be sent.
	Hint any
	// Let Specifies parameters for the aggregate expression. This option is only valid for MongoDB versions >= 5.0. Older
	// servers will report an error for using this option. This must be a document mapping parameter names to values.
	// Values must be constant or closed expressions that do not reference document fields. Parameters can then be
	// accessed as variables in an aggregate expression context (e.g. "$$var").
	Let any
	// Custom options to be added to aggregate expression. Key-value pairs of the BSON map should correlate with desired
	// option names and values. Values must be Marshaller. Custom options may conflict with non-custom options, and custom
	// options bypass client-side validation. Prefer using non-custom options where possible.
	Custom bson.M
}

Aggregate represents options that can be used to configure an 'Aggregate' operation.

func MergeAggregateByParams added in v1.1.2

func MergeAggregateByParams(opts []*Aggregate) *Aggregate

MergeAggregateByParams assembles the Aggregate object from optional parameters.

func NewAggregate

func NewAggregate() *Aggregate

NewAggregate creates a new Aggregate instance.

func (*Aggregate) SetAllowDiskUse

func (a *Aggregate) SetAllowDiskUse(b bool) *Aggregate

SetAllowDiskUse sets value for the AllowDiskUse field.

func (*Aggregate) SetBatchSize

func (a *Aggregate) SetBatchSize(i int32) *Aggregate

SetBatchSize sets value for the BatchSize field.

func (*Aggregate) SetBypassDocumentValidation

func (a *Aggregate) SetBypassDocumentValidation(b bool) *Aggregate

SetBypassDocumentValidation sets value for the BypassDocumentValidation field.

func (*Aggregate) SetCollation

func (a *Aggregate) SetCollation(c *Collation) *Aggregate

SetCollation sets value for the Collation field.

func (*Aggregate) SetComment

func (a *Aggregate) SetComment(s string) *Aggregate

SetComment sets value for the Comment field.

func (*Aggregate) SetCustom

func (a *Aggregate) SetCustom(b bson.M) *Aggregate

SetCustom sets value for the Custom field.

func (*Aggregate) SetHint

func (a *Aggregate) SetHint(v any) *Aggregate

SetHint sets value for the Hint field.

func (*Aggregate) SetLet

func (a *Aggregate) SetLet(v any) *Aggregate

SetLet sets value for the Let field.

func (*Aggregate) SetMaxAwaitTime

func (a *Aggregate) SetMaxAwaitTime(d time.Duration) *Aggregate

SetMaxAwaitTime sets value for the MaxAwaitTime field.

func (*Aggregate) SetMaxTime

func (a *Aggregate) SetMaxTime(d time.Duration) *Aggregate

SetMaxTime sets value for the MaxTime field.

type ArrayFilters

type ArrayFilters struct {
	// Registry is the registry to use for converting filters. Defaults to bson.DefaultRegistry.
	//
	// Deprecated: Marshaling ArrayFilters to BSON will not be supported in Go Driver 2.0.
	Registry *bsoncodec.Registry
	// Filters The filters to apply
	Filters []any
}

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.

type Collation

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

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

type Count

type Count struct {
	// Collation Specifies a collation to use for string comparisons during the operation. This option is only valid
	// for MongoDB  versions >= 3.4. For previous server versions, the driver will return an error if this option is
	// used. The default value is nil, which means the default collation of the collection will be used.
	Collation *Collation
	// Comment A string or document that will be included in server logs, profiling logs, and currentOp queries to help
	// trace the operation. The default is nil, which means that no comment will be included in the logs.
	Comment *string
	// Hint The index to use for the aggregation. This should either be the index name as a string or the index specification
	// as a document. The driver will return an error if the hint parameter is a multi-key map. The default value is nil,
	// which means that no hint will be sent.
	Hint any
	// Limit The maximum number of documents to count. The default value is 0, which means that there is no limit and all
	// documents matching the filter will be counted.
	Limit *int64
	// MaxTime The maximum amount of time that the query can run on the server. The default value is nil, meaning that
	// there is no time limit for query execution.
	//
	// NOTE: MaxTime will be deprecated in a future release. The more general Timeout option may be used in
	// its place to control the amount of time that a single operation can run before returning an error. MaxTime is
	// ignored if Timeout is set on the client.
	MaxTime *time.Duration
	// Skip
	// The number of documents to skip before counting. The default value is 0.
	Skip *int64
}

Count represents options that can be used to configure a 'CountDocuments' operation.

func MergeCountByParams added in v1.1.2

func MergeCountByParams(opts []*Count) Count

MergeCountByParams assembles the Count object from optional parameters.

func NewCount

func NewCount() *Count

NewCount creates a new Count instance.

func (*Count) SetCollation

func (c *Count) SetCollation(collation *Collation) *Count

SetCollation sets value for the Collation field.

func (*Count) SetComment

func (c *Count) SetComment(comment string) *Count

SetComment sets value for the Comment field.

func (*Count) SetHint

func (c *Count) SetHint(a any) *Count

SetHint sets value for the Hint field.

func (*Count) SetLimit

func (c *Count) SetLimit(i int64) *Count

SetLimit sets value for the Limit field.

func (*Count) SetMaxTime

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

SetMaxTime sets value for the MaxTime field.

func (*Count) SetSkip

func (c *Count) SetSkip(i int64) *Count

SetSkip sets value for the Skip field.

type CursorType

type CursorType int8

CursorType specifies whether a cursor should close when the last data is retrieved. See NonTailable, Tailable, and TailableAwait.

const (
	// CursorTypeNonTailable specifies that a cursor should close after retrieving the last data.
	CursorTypeNonTailable CursorType = iota
	// CursorTypeTailable specifies that a cursor should not close when the last data is retrieved and can be resumed later.
	CursorTypeTailable
	// CursorTypeTailableAwait 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.
	CursorTypeTailableAwait
)

type Delete

type Delete struct {
	// Collation Specifies a collation to use for string comparisons during the operation. This option is only valid
	// for MongoDB  versions >= 3.4. For previous server versions, the driver will return an error if this option is
	// used. The default value is nil, which means the default collation of the collection will be used.
	Collation *Collation
	// Comment A string or document that will be included in server logs, profiling logs, and currentOp queries to help trace
	// the operation. The default value is nil, which means that no comment will be included in the logs.
	Comment any
	// Hint The index to use for the operation. This should either be the index name as a string or the index specification
	// as a document. This option is only valid for MongoDB versions >= 4.4. Server versions >= 3.4 will return an error
	// if this option is specified. For server versions < 3.4, the driver will return a client-side error if this option
	// is specified. The driver will return an error if this option is specified during an unacknowledged write
	// operation. The driver will return an error if the hint parameter is a multi-key map. The default value is nil,
	// which means that no hint will be sent.
	Hint any
	// Let Specifies parameters for the delete expression. This option is only valid for MongoDB versions >= 5.0. Older
	// servers will report an error for using this option. This must be a document mapping parameter names to values.
	// Values must be constant or closed expressions that do not reference document fields. Parameters can then be
	// accessed as variables in an aggregate expression context (e.g. "$$var").
	Let any
	// DisableAutoRollbackSession disable auto rollback if an error occurs.
	DisableAutoRollbackSession *bool
	// DisableAutoCloseSession Disable automatic closing session, if true, we automatically close session according to
	// the result, if an error occurs, we abort the transaction, otherwise, we commit the transaction.
	// default is false
	DisableAutoCloseSession *bool
	// ForceRecreateSession Force the creation of the session, if any session is still open, we close it automatically,
	// committing the transactions, and continue creating a new session.
	// default is false
	ForceRecreateSession *bool
}

Delete represents options that can be used to configure DeleteOne and DeleteMany operations.

func MergeDeleteByParams added in v1.1.2

func MergeDeleteByParams(opts []*Delete, global *Global) *Delete

MergeDeleteByParams assembles the Delete object from optional parameters.

func NewDelete

func NewDelete() *Delete

NewDelete creates a new Delete instance.

func (*Delete) SetCollation

func (d *Delete) SetCollation(c *Collation) *Delete

SetCollation sets value for the Collation field.

func (*Delete) SetComment

func (d *Delete) SetComment(a any) *Delete

SetComment sets value for the Comment field.

func (*Delete) SetDisableAutoCloseSession

func (d *Delete) SetDisableAutoCloseSession(b bool) *Delete

SetDisableAutoCloseSession sets value for the DisableAutoCloseSession field.

func (*Delete) SetDisableAutoRollbackSession added in v1.0.3

func (d *Delete) SetDisableAutoRollbackSession(b bool) *Delete

SetDisableAutoRollbackSession sets value for the DisableAutoRollbackSession field.

func (*Delete) SetForceRecreateSession

func (d *Delete) SetForceRecreateSession(b bool) *Delete

SetForceRecreateSession sets value for the ForceRecreateSession field.

func (*Delete) SetHint

func (d *Delete) SetHint(a any) *Delete

SetHint sets value for the Hint field.

func (*Delete) SetLet

func (d *Delete) SetLet(a any) *Delete

SetLet sets value for the Let field.

type Distinct

type Distinct struct {
	// Collation Specifies a collation to use for string comparisons during the operation. This option is only valid
	// for MongoDB  versions >= 3.4. For previous server versions, the driver will return an error if this option is
	// used. The default value is nil, which means the default collation of the collection will be used.
	Collation *Collation
	// A string or document that will be included in server logs, profiling logs, and currentOp queries to help trace
	// the operation. The default value is nil, which means that no comment will be included in the logs.
	Comment any
	// MaxTime The maximum amount of time that the query can run on the server. The default value is nil, meaning that
	// there is no time limit for query execution.
	//
	// NOTE: MaxTime will be deprecated in a future release. The more general Timeout option may be used in
	// its place to control the amount of time that a single operation can run before returning an error. MaxTime is
	// ignored if Timeout is set on the client.
	MaxTime *time.Duration
}

Distinct represents options that can be used to configure a Distinct operation.

func MergeDistinctByParams added in v1.1.2

func MergeDistinctByParams(opts []*Distinct) *Distinct

MergeDistinctByParams assembles the Distinct object from optional parameters.

func NewDistinct

func NewDistinct() *Distinct

NewDistinct creates a new Distinct instance.

func (*Distinct) SetCollation

func (d *Distinct) SetCollation(c *Collation) *Distinct

SetCollation sets value for the Collation field.

func (*Distinct) SetComment

func (d *Distinct) SetComment(comment any) *Distinct

SetComment sets value for the Comment field.

func (*Distinct) SetMaxTime

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

SetMaxTime sets value for the MaxTime field.

type DropIndex

type DropIndex struct {
	// MaxTime The maximum amount of time that the query can run on the server. The default value is nil, meaning that
	// there is no time limit for query execution.
	//
	// NOTE: MaxTime will be deprecated in a future release. The more general Timeout option may be used in
	// its place to control the amount of time that a single operation can run before returning an error. MaxTime is
	// ignored if Timeout is set on the client.
	MaxTime *time.Duration
}

DropIndex represents options that can be used to configure a DropOneIndex and DropAllIndexes operation.

func MergeDropIndexByParams added in v1.1.2

func MergeDropIndexByParams(opts []*DropIndex) *DropIndex

MergeDropIndexByParams assembles the DropIndex object from optional parameters.

func NewDropIndex

func NewDropIndex() *DropIndex

NewDropIndex creates a new DropIndex instance.

func (*DropIndex) SetMaxTime

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

SetMaxTime creates a new MaxTime instance.

type EstimatedDocumentCount

type EstimatedDocumentCount struct {
	// Comment A string or document that will be included in server logs, profiling logs, and currentOp queries to help trace
	// the operation.  The default is nil, which means that no comment will be included in the logs.
	Comment any
	// MaxTime The maximum amount of time that the query can run on the server. The default value is nil, meaning that
	// there is no time limit for query execution.
	//
	// NOTE: MaxTime will be deprecated in a future release. The more general Timeout option may be used in
	// its place to control the amount of time that a single operation can run before returning an error. MaxTime is
	// ignored if Timeout is set on the client.
	MaxTime *time.Duration
}

EstimatedDocumentCount represents options that can be used to configure an 'EstimatedDocumentCount' operation.

func MergeEstimatedDocumentCountByParams added in v1.1.2

func MergeEstimatedDocumentCountByParams(opts []*EstimatedDocumentCount) *EstimatedDocumentCount

MergeEstimatedDocumentCountByParams assembles the EstimatedDocumentCount object from optional parameters.

func NewEstimatedDocumentCount

func NewEstimatedDocumentCount() *EstimatedDocumentCount

NewEstimatedDocumentCount creates a new EstimatedDocumentCount instance.

func (*EstimatedDocumentCount) SetComment

SetComment sets value for the Comment field.

func (*EstimatedDocumentCount) SetMaxTime

SetMaxTime sets value for the MaxTime field.

type Exists

type Exists struct {
	// Collation Specifies a collation to use for string comparisons during the operation. This option is only valid
	// for MongoDB  versions >= 3.4. For previous server versions, the driver will return an error if this option is
	// used. The default value is nil, which means the default collation of the collection will be used.
	Collation *Collation
	// A string or document that will be included in server logs, profiling logs, and currentOp queries to help trace
	// the operation.  The default is nil, which means that no comment will be included in the logs.
	Comment *string
	// The index to use for the aggregation. This should either be the index name as a string or the index specification
	// as a document. The driver will return an error if the hint parameter is a multi-key map. The default value is nil,
	// which means that no hint will be sent.
	Hint any
	// MaxTime The maximum amount of time that the query can run on the server. The default value is nil, meaning that
	// there is no time limit for query execution.
	//
	// NOTE: MaxTime will be deprecated in a future release. The more general Timeout option may be used in
	// its place to control the amount of time that a single operation can run before returning an error. MaxTime is
	// ignored if Timeout is set on the client.
	MaxTime *time.Duration
}

Exists represents options that can be used to configure an 'Exists' operation.

func MergeExistsByParams added in v1.1.2

func MergeExistsByParams(opts []*Exists) *Exists

MergeExistsByParams assembles the Exists object from optional parameters.

func NewExists

func NewExists() *Exists

NewExists creates a new Exists instance.

func (*Exists) SetCollation

func (e *Exists) SetCollation(collation *Collation) *Exists

SetCollation creates a new Collation instance.

func (*Exists) SetComment

func (e *Exists) SetComment(comment string) *Exists

SetComment creates a new Comment instance.

func (*Exists) SetHint

func (e *Exists) SetHint(a any) *Exists

SetHint creates a new Hint instance.

func (*Exists) SetMaxTime

func (e *Exists) SetMaxTime(d time.Duration) *Exists

SetMaxTime creates a new MaxTime instance.

type Find

type Find struct {
	// AllowDiskUse specifies whether the server can write temporary data to disk while executing the Find operation.
	// This option is only valid for MongoDB versions >= 4.4. Server versions >= 3.2 will report an error if this option
	// is specified. For server versions < 3.2, the driver will return a client-side error if this option is specified.
	// The default value is false.
	AllowDiskUse *bool
	// AllowPartialResults AllowPartial results specifies whether the Find operation on a sharded cluster can
	// return partial results if some shards are down rather than returning an error. The default value is false.
	AllowPartialResults *bool
	// BatchSize is the maximum number of documents to be included in each batch returned by the server.
	BatchSize *int32
	// Collation Specifies a collation to use for string comparisons during the operation. This option is only valid
	// for MongoDB  versions >= 3.4. For previous server versions, the driver will return an error if this option is
	// used. The default value is nil, which means the default collation of the collection will be used.
	Collation *Collation
	// Comment A string that will be included in server logs, profiling logs, and currentOp queries to help trace the operation.
	// The default is nil, which means that no comment will be included in the logs.
	Comment *string
	// CursorType specifies the type of cursor that should be created for the operation. The default is NonTailable, which
	// means that the cursor will be closed by the server when the last batch of documents is retrieved.
	CursorType *CursorType
	// Hint is the index to use for the Find operation. This should either be the index name as a string or the index
	// specification as a document. The driver will return an error if the hint parameter is a multi-key map. The default
	// value is nil, which means that no hint will be sent.
	Hint any
	// Limit is the maximum number of documents to return. The default value is 0, which means that all documents matching the
	// filter will be returned. A negative limit specifies that the resulting documents should be returned in a single
	// batch. The default value is 0.
	Limit *int64
	// Max is a document specifying the exclusive upper bound for a specific index. The default value is nil, which means that
	// there is no maximum value.
	Max any
	// MaxAwaitTime is the maximum amount of time that the server should wait for new documents to satisfy a tailable cursor
	// query. This option is only valid for tailable await cursors (see the CursorType option for more information) and
	// MongoDB versions >= 3.2. For other cursor types or previous server versions, this option is ignored.
	MaxAwaitTime *time.Duration
	// MaxTime The maximum amount of time that the query can run on the server. The default value is nil, meaning that
	// there is no time limit for query execution.
	//
	// NOTE: MaxTime will be deprecated in a future release. The more general Timeout option may be used in
	// its place to control the amount of time that a single operation can run before returning an error. MaxTime is
	// ignored if Timeout is set on the client.
	MaxTime *time.Duration
	// Min is a document specifying the inclusive lower bound for a specific index. The default value is 0, which means that
	// there is no minimum value.
	Min any
	// NoCursorTimeout specifies whether the cursor created by the operation will not time out after a period of inactivity.
	// The default value is false.
	NoCursorTimeout *bool
	// Projection Project is a document describing which fields will be included in the documents returned by the Find
	// operation. The default value is nil, which means all fields will be included.
	Projection any
	// ReturnKey specifies whether the documents returned by the Find operation will only contain fields corresponding to the
	// index used. The default value is false.
	ReturnKey *bool
	// ShowRecordID specifies whether a $recordId field with a record identifier will be included in the documents returned by
	// the Find operation. The default value is false.
	ShowRecordID *bool
	// Skip is the number of documents to skip before adding documents to the result. The default value is 0.
	Skip *int64
	// Sort is a document specifying the order in which documents should be returned.  The driver will return an error if the
	// sort parameter is a multi-key map.
	Sort any
	// Let specifies parameters for the find expression. This option is only valid for MongoDB versions >= 5.0. Older
	// servers will report an error for using this option. This must be a document mapping parameter names to values.
	// Values must be constant or closed expressions that do not reference document fields. Parameters can then be
	// accessed as variables in an aggregate expression context (e.g. "$$var").
	Let any
}

Find represents options that can be used to configure a 'Find' operation.

func MergeFindByParams added in v1.1.2

func MergeFindByParams(opts []*Find) *Find

MergeFindByParams assembles the Find object from optional parameters.

func NewFind

func NewFind() *Find

NewFind creates a new Find instance.

func (*Find) SetAllowDiskUse

func (f *Find) SetAllowDiskUse(b bool) *Find

SetAllowDiskUse creates a new AllowDiskUse instance.

func (*Find) SetAllowPartialResults

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

SetAllowPartialResults creates a new AllowPartialResults instance.

func (*Find) SetBatchSize

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

SetBatchSize creates a new BatchSize instance.

func (*Find) SetCollation

func (f *Find) SetCollation(c *Collation) *Find

SetCollation creates a new Collation instance.

func (*Find) SetComment

func (f *Find) SetComment(s string) *Find

SetComment creates a new Comment instance.

func (*Find) SetCursorType

func (f *Find) SetCursorType(c CursorType) *Find

SetCursorType creates a new CursorType instance.

func (*Find) SetHint

func (f *Find) SetHint(v any) *Find

SetHint creates a new Hint instance.

func (*Find) SetLet

func (f *Find) SetLet(v any) *Find

SetLet creates a new Let instance.

func (*Find) SetLimit

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

SetLimit creates a new Limit instance.

func (*Find) SetMax

func (f *Find) SetMax(v any) *Find

SetMax creates a new Max instance.

func (*Find) SetMaxAwaitTime

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

SetMaxAwaitTime creates a new MaxAwaitTime instance.

func (*Find) SetMaxTime

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

SetMaxTime creates a new MaxTime instance.

func (*Find) SetMin

func (f *Find) SetMin(v any) *Find

SetMin creates a new Min instance.

func (*Find) SetNoCursorTimeout

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

SetNoCursorTimeout creates a new NoCursorTimeout instance.

func (*Find) SetProjection

func (f *Find) SetProjection(v any) *Find

SetProjection creates a new Projection instance.

func (*Find) SetReturnKey

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

SetReturnKey creates a new ReturnKey instance.

func (*Find) SetShowRecordID

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

SetShowRecordID creates a new ShowRecordID instance.

func (*Find) SetSkip

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

SetSkip creates a new Skip instance.

func (*Find) SetSort

func (f *Find) SetSort(a any) *Find

SetSort creates a new Sort instance.

type FindOne

type FindOne struct {
	// AllowPartialResults If true, an operation on a sharded cluster can return partial results if some shards are
	// down rather than returning an error. The default value is false.
	AllowPartialResults *bool
	// Collation Specifies a collation to use for string comparisons during the operation. This option is only valid
	// for MongoDB  versions >= 3.4. For previous server versions, the driver will return an error if this option is
	// used. The default value is nil, which means the default collation of the collection will be used.
	Collation *Collation
	// Comment A string that will be included in server logs, profiling logs, and currentOp queries to help trace the operation.
	// The default is nil, which means that no comment will be included in the logs.
	Comment *string
	// Hint The index to use for the aggregation. This should either be the index name as a string or the index specification
	// as a document. The driver will return an error if the hint parameter is a multi-key map. The default value is nil,
	// which means that no hint will be sent.
	Hint any
	// Max A document specifying the exclusive upper bound for a specific index. The default value is nil, which means that
	// there is no maximum value.
	Max any
	// MaxTime The maximum amount of time that the query can run on the server. The default value is nil, meaning that
	// there is no time limit for query execution.
	//
	// NOTE: MaxTime will be deprecated in a future release. The more general Timeout option may be used in
	// its place to control the amount of time that a single operation can run before returning an error. MaxTime is
	// ignored if Timeout is set on the client.
	MaxTime *time.Duration
	// Min A document specifying the inclusive lower bound for a specific index. The default value is 0, which means that
	// there is no minimum value.
	Min any
	// Projection A document describing which fields will be included in the document returned by the operation.
	// The default value is nil, which means all fields will be included.
	Projection any
	// ReturnKey If true, the document returned by the operation will only contain fields corresponding to the index
	// used. The default value is false.
	ReturnKey *bool
	// ShowRecordID If true, a $recordId field with a record identifier will be included in the document returned by
	// the operation. The default value is false.
	ShowRecordID *bool
	// Skip The number of documents to skip before selecting the document to be returned. The default value is 0.
	Skip *int64
	// Sort A document specifying the sort order to apply to the query. The first document in the sorted order will be
	// returned. The driver will return an error if the sort parameter is a multi-key map.
	Sort any
}

FindOne represents options that can be used to configure a FindOne operation.

func MergeFindOneByParams added in v1.1.2

func MergeFindOneByParams(opts []*FindOne) *FindOne

MergeFindOneByParams assembles the FindOne object from optional parameters.

func NewFindOne

func NewFindOne() *FindOne

NewFindOne creates a new FindOne instance.

func (*FindOne) SetAllowPartialResults

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

SetAllowPartialResults creates a new AllowPartialResults instance.

func (*FindOne) SetCollation

func (f *FindOne) SetCollation(c *Collation) *FindOne

SetCollation creates a new Collation instance.

func (*FindOne) SetComment

func (f *FindOne) SetComment(s string) *FindOne

SetComment creates a new Comment instance.

func (*FindOne) SetHint

func (f *FindOne) SetHint(v any) *FindOne

SetHint creates a new Hint instance.

func (*FindOne) SetMax

func (f *FindOne) SetMax(v any) *FindOne

SetMax creates a new Max instance.

func (*FindOne) SetMaxTime

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

SetMaxTime creates a new MaxTime instance.

func (*FindOne) SetMin

func (f *FindOne) SetMin(v any) *FindOne

SetMin creates a new Min instance.

func (*FindOne) SetProjection

func (f *FindOne) SetProjection(v any) *FindOne

SetProjection creates a new Projection instance.

func (*FindOne) SetReturnKey

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

SetReturnKey creates a new ReturnKey instance.

func (*FindOne) SetShowRecordID

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

SetShowRecordID creates a new ShowRecordID instance.

func (*FindOne) SetSkip

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

SetSkip creates a new Skip instance.

func (*FindOne) SetSort

func (f *FindOne) SetSort(a any) *FindOne

SetSort creates a new Sort instance.

type FindOneAndDelete

type FindOneAndDelete struct {
	// Collation Specifies a collation to use for string comparisons during the operation. This option is only valid
	// for MongoDB  versions >= 3.4. For previous server versions, the driver will return an error if this option is
	// used. The default value is nil, which means the default collation of the collection will be used.
	Collation *Collation
	// Comment A string or document that will be included in server logs, profiling logs, and currentOp queries to help trace
	// the operation.  The default value is nil, which means that no comment will be included in the logs.
	Comment any
	// MaxTime The maximum amount of time that the query can run on the server. The default value is nil, meaning that
	// there is no time limit for query execution.
	//
	// NOTE: MaxTime will be deprecated in a future release. The more general Timeout option may be used in
	// its place to control the amount of time that a single operation can run before returning an error. MaxTime is
	// ignored if Timeout is set on the client.
	MaxTime *time.Duration
	// Projection A document describing which fields will be included in the document returned by the operation.
	// The default value is nil, which means all fields will be included.
	Projection any
	// Sort A document specifying which document should be replaced if the filter used by the operation matches multiple
	// documents in the collection. If set, the first document in the sorted order will be selected for replacement.
	// The driver will return an error if the sort parameter is a multi-key map. The default value is nil.
	Sort any
	// Hint The index to use for the operation. This should either be the index name as a string or the index specification
	// as a document. This option is only valid for MongoDB versions >= 4.4. MongoDB version 4.2 will report an error if
	// this option is specified. For server versions < 4.2, the driver will return an error if this option is specified.
	// The driver will return an error if this option is used with during an unacknowledged write operation. The driver
	// will return an error if the hint parameter is a multi-key map. The default value is nil, which means that no hint
	// will be sent.
	Hint any
	// Let Specifies parameters for the find one and delete expression. This option is only valid for
	// MongoDB versions >= 5.0. Older servers will report an error for using this option. This must be a document
	// mapping parameter names to values. Values must be constant or closed expressions that do not reference document
	// fields. Parameters can then be accessed as variables in an aggregate expression context (e.g. "$$var").
	Let any
	// DisableAutoRollbackSession disable auto rollback if an error occurs.
	DisableAutoRollbackSession *bool
	// DisableAutoCloseSession Disable automatic closing session, if true, we automatically close session according to
	// the result, if an error occurs, we abort the transaction, otherwise, we commit the transaction.
	// default is false.
	DisableAutoCloseSession *bool
	// ForceRecreateSession Force the creation of the session, if any session is still open, we close it automatically,
	// committing the transactions, and continue creating a new session.
	// default is false.
	ForceRecreateSession *bool
}

FindOneAndDelete represents options that can be used to configure a FindOneAndDelete operation.

func MergeFindOneAndDeleteByParams added in v1.1.2

func MergeFindOneAndDeleteByParams(opts []*FindOneAndDelete, global *Global) *FindOneAndDelete

MergeFindOneAndDeleteByParams assembles the FindOneAndDelete object from optional parameters.

func NewFindOneAndDelete

func NewFindOneAndDelete() *FindOneAndDelete

NewFindOneAndDelete creates a new FindOneAndDelete instance.

func (*FindOneAndDelete) SetCollation

func (f *FindOneAndDelete) SetCollation(c *Collation) *FindOneAndDelete

SetCollation creates a new Collation instance.

func (*FindOneAndDelete) SetComment

func (f *FindOneAndDelete) SetComment(a any) *FindOneAndDelete

SetComment creates a new Comment instance.

func (*FindOneAndDelete) SetDisableAutoCloseSession

func (f *FindOneAndDelete) SetDisableAutoCloseSession(b bool) *FindOneAndDelete

SetDisableAutoCloseSession creates a new DisableAutoCloseSession instance.

func (*FindOneAndDelete) SetDisableAutoRollbackSession added in v1.2.1

func (f *FindOneAndDelete) SetDisableAutoRollbackSession(b bool) *FindOneAndDelete

SetDisableAutoRollbackSession creates a new DisableAutoRollbackSession instance.

func (*FindOneAndDelete) SetForceRecreateSession

func (f *FindOneAndDelete) SetForceRecreateSession(b bool) *FindOneAndDelete

SetForceRecreateSession creates a new ForceRecreateSession instance.

func (*FindOneAndDelete) SetHint

func (f *FindOneAndDelete) SetHint(v any) *FindOneAndDelete

SetHint creates a new Hint instance.

func (*FindOneAndDelete) SetLet

func (f *FindOneAndDelete) SetLet(v any) *FindOneAndDelete

SetLet creates a new Let instance.

func (*FindOneAndDelete) SetMaxTime

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

SetMaxTime creates a new MaxTime instance.

func (*FindOneAndDelete) SetProjection

func (f *FindOneAndDelete) SetProjection(v any) *FindOneAndDelete

SetProjection creates a new Projection instance.

func (*FindOneAndDelete) SetSort

func (f *FindOneAndDelete) SetSort(a any) *FindOneAndDelete

SetSort creates a new Sort instance.

type FindOneAndReplace

type FindOneAndReplace struct {
	// BypassDocumentValidation If true, writes executed as part of the operation will opt out of document-level
	// validation on the server. This option is valid for MongoDB versions >= 3.2 and is ignored for previous server
	// versions. The default value is false. See https://www.mongodb.com/docs/manual/core/schema-validation/ for more
	// information about document validation.
	BypassDocumentValidation *bool
	// Collation Specifies a collation to use for string comparisons during the operation. This option is only valid
	// for MongoDB  versions >= 3.4. For previous server versions, the driver will return an error if this option is
	// used. The default value is nil, which means the default collation of the collection will be used.
	Collation *Collation
	// Comment A string or document that will be included in server logs, profiling logs, and currentOp queries to help trace
	// the operation.  The default value is nil, which means that no comment will be included in the logs.
	Comment any
	// MaxTime The maximum amount of time that the query can run on the server. The default value is nil, meaning that
	// there is no time limit for query execution.
	//
	// NOTE: MaxTime will be deprecated in a future release. The more general Timeout option may be used in
	// its place to control the amount of time that a single operation can run before returning an error. MaxTime is
	// ignored if Timeout is set on the client.
	MaxTime *time.Duration
	// Projection A document describing which fields will be included in the document returned by the operation.
	// The default value is nil, which means all fields will be included.
	Projection any
	// ReturnDocument Specifies whether the original or replaced document should be returned by the operation.
	// The default value is Before, which means the original document will be returned from before the replacement is performed.
	ReturnDocument *ReturnDocument
	// Sort A document specifying which document should be replaced if the filter used by the operation matches multiple
	// documents in the collection. If set, the first document in the sorted order will be replaced. The driver will
	// return an error if the sort parameter is a multi-key map. The default value is nil.
	Sort any
	// Upsert If true, a new document will be inserted if the filter does not match any documents in the collection. The
	// default value is false.
	Upsert *bool
	// Hint The index to use for the operation. This should either be the index name as a string or the index specification
	// as a document. This option is only valid for MongoDB versions >= 4.4. MongoDB version 4.2 will report an error if
	// this option is specified. For server versions < 4.2, the driver will return an error if this option is specified.
	// The driver will return an error if this option is used with during an unacknowledged write operation. The driver
	// will return an error if the hint parameter is a multi-key map. The default value is nil, which means that no hint
	// will be sent.
	Hint any
	// Let Specifies parameters for the find one and replace expression. This option is only valid for MongoDB
	// versions >= 5.0. Older servers will report an error for using this option. This must be a document mapping
	// parameter names to values. Values must be constant or closed expressions that do not reference document fields.
	// Parameters can then be accessed as variables in an aggregate expression context (e.g. "$$var").
	Let any
	// DisableAutoRollbackSession disable auto rollback if an error occurs.
	DisableAutoRollbackSession *bool
	// DisableAutoCloseSession Disable automatic closing session, if true, we automatically close session according to
	// the result, if an error occurs, we abort the transaction, otherwise, we commit the transaction.
	// default is false.
	DisableAutoCloseSession *bool
	// ForceRecreateSession Force the creation of the session, if any session is still open, we close it automatically,
	// committing the transactions, and continue creating a new session.
	// default is false.
	ForceRecreateSession *bool
}

FindOneAndReplace represents options that can be used to configure a FindOneAndReplace operation.

func MergeFindOneAndReplaceByParams added in v1.1.2

func MergeFindOneAndReplaceByParams(opts []*FindOneAndReplace, global *Global) *FindOneAndReplace

MergeFindOneAndReplaceByParams assembles the FindOneAndReplace object from optional parameters.

func NewFindOneAndReplace

func NewFindOneAndReplace() *FindOneAndReplace

NewFindOneAndReplace creates a new FindOneAndReplace instance.

func (*FindOneAndReplace) SetBypassDocumentValidation

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

SetBypassDocumentValidation sets value for the BypassDocumentValidation field.

func (*FindOneAndReplace) SetCollation

func (f *FindOneAndReplace) SetCollation(c *Collation) *FindOneAndReplace

SetCollation sets value for the Collation field.

func (*FindOneAndReplace) SetComment

func (f *FindOneAndReplace) SetComment(a any) *FindOneAndReplace

SetComment sets value for the Comment field.

func (*FindOneAndReplace) SetDisableAutoCloseSession

func (f *FindOneAndReplace) SetDisableAutoCloseSession(b bool) *FindOneAndReplace

SetDisableAutoCloseSession creates a new DisableAutoCloseSession instance.

func (*FindOneAndReplace) SetDisableAutoRollbackSession added in v1.2.1

func (f *FindOneAndReplace) SetDisableAutoRollbackSession(b bool) *FindOneAndReplace

SetDisableAutoRollbackSession creates a new DisableAutoCloseSession instance.

func (*FindOneAndReplace) SetForceRecreateSession

func (f *FindOneAndReplace) SetForceRecreateSession(b bool) *FindOneAndReplace

SetForceRecreateSession sets value for the ForceRecreateSession field.

func (*FindOneAndReplace) SetHint

func (f *FindOneAndReplace) SetHint(v any) *FindOneAndReplace

SetHint sets value for the Hint field.

func (*FindOneAndReplace) SetLet

func (f *FindOneAndReplace) SetLet(v any) *FindOneAndReplace

SetLet sets value for the Let field.

func (*FindOneAndReplace) SetMaxTime

SetMaxTime creates a new MaxTime instance.

func (*FindOneAndReplace) SetProjection

func (f *FindOneAndReplace) SetProjection(v any) *FindOneAndReplace

SetProjection creates a new Projection instance.

func (*FindOneAndReplace) SetReturnDocument

func (f *FindOneAndReplace) SetReturnDocument(r ReturnDocument) *FindOneAndReplace

SetReturnDocument creates a new ReturnDocument instance.

func (*FindOneAndReplace) SetSort

func (f *FindOneAndReplace) SetSort(a any) *FindOneAndReplace

SetSort creates a new Sort instance.

func (*FindOneAndReplace) SetUpsert

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

SetUpsert creates a new Upsert instance.

type FindOneAndUpdate

type FindOneAndUpdate struct {
	// ArrayFilters A set of filters specifying to which array elements an update should apply. This option is only
	// valid for MongoDB versions >= 3.6. For previous server versions, the driver will return an error if this option
	// is used. The default value is nil, which means the update will apply to all array elements.
	ArrayFilters *ArrayFilters
	// BypassDocumentValidation If true, writes executed as part of the operation will opt out of document-level
	// validation on the server. This option is valid for MongoDB versions >= 3.2 and is ignored for previous server
	// versions. The default value is false. See https://www.mongodb.com/docs/manual/core/schema-validation/ for more
	// information about document validation.
	BypassDocumentValidation *bool
	// Collation Specifies a collation to use for string comparisons during the operation. This option is only valid
	// for MongoDB  versions >= 3.4. For previous server versions, the driver will return an error if this option is
	// used. The default value is nil, which means the default collation of the collection will be used.
	Collation *Collation
	// Comment A string or document that will be included in server logs, profiling logs, and currentOp queries to help trace
	// the operation.  The default value is nil, which means that no comment will be included in the logs.
	Comment any
	// MaxTime The maximum amount of time that the query can run on the server. The default value is nil, meaning that
	// there is no time limit for query execution.
	//
	// NOTE: MaxTime will be deprecated in a future release. The more general Timeout option may be used in
	// its place to control the amount of time that a single operation can run before returning an error. MaxTime is
	// ignored if Timeout is set on the client.
	MaxTime *time.Duration
	// Projection A document describing which fields will be included in the document returned by the operation.
	// The default value is nil, which means all fields will be included.
	Projection any
	// ReturnDocument Specifies whether the original or replaced document should be returned by the operation.
	// The default value is Before, which means the original document will be returned before the replacement is performed.
	ReturnDocument *ReturnDocument
	// Sort A document specifying which document should be updated if the filter used by the operation matches multiple
	// documents in the collection. If set, the first document in the sorted order will be updated. The driver will
	// return an error if the sort parameter is a multi-key map. The default value is nil.
	Sort any
	// Upsert If true, a new document will be inserted if the filter does not match any documents in the collection. The
	// default value is false.
	Upsert *bool
	// Hint The index to use for the operation. This should either be the index name as a string or the index specification
	// as a document. This option is only valid for MongoDB versions >= 4.4. MongoDB version 4.2 will report an error if
	// this option is specified. For server versions < 4.2, the driver will return an error if this option is specified.
	// The driver will return an error if this option is used with during an unacknowledged write operation. The driver
	// will return an error if the hint parameter is a multi-key map. The default value is nil, which means that no hint
	// will be sent.
	Hint any
	// Let Specifies parameters for the find one and update expression. This option is only valid for MongoDB versions >= 5.0. Older
	// servers will report an error for using this option. This must be a document mapping parameter names to values.
	// Values must be constant or closed expressions that do not reference document fields. Parameters can then be
	// accessed as variables in an aggregate expression context (e.g. "$$var").
	Let any
	// DisableAutoRollbackSession disable auto rollback if an error occurs.
	DisableAutoRollbackSession *bool
	// DisableAutoCloseSession Disable automatic closing session, if true, we automatically close session according to
	// the result, if an error occurs, we abort the transaction, otherwise, we commit the transaction.
	// default is false
	DisableAutoCloseSession *bool
	// ForceRecreateSession Force the creation of the session, if any session is still open, we close it automatically,
	// committing the transactions, and continue creating a new session.
	// default is false
	ForceRecreateSession *bool
}

FindOneAndUpdate represents options that can be used to configure a FindOneAndUpdate operation.

func MergeFindOneAndUpdateByParams added in v1.1.2

func MergeFindOneAndUpdateByParams(opts []*FindOneAndUpdate, global *Global) *FindOneAndUpdate

MergeFindOneAndUpdateByParams assembles the FindOneAndUpdate object from optional parameters.

func NewFindOneAndUpdate

func NewFindOneAndUpdate() *FindOneAndUpdate

NewFindOneAndUpdate creates a new FindOneAndUpdate instance.

func (*FindOneAndUpdate) SetArrayFilters

func (f *FindOneAndUpdate) SetArrayFilters(a *ArrayFilters) *FindOneAndUpdate

func (*FindOneAndUpdate) SetBypassDocumentValidation

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

SetBypassDocumentValidation sets value for the BypassDocumentValidation field.

func (*FindOneAndUpdate) SetCollation

func (f *FindOneAndUpdate) SetCollation(c *Collation) *FindOneAndUpdate

SetCollation sets value for the Collation field.

func (*FindOneAndUpdate) SetComment

func (f *FindOneAndUpdate) SetComment(a any) *FindOneAndUpdate

SetComment sets value for the Comment field.

func (*FindOneAndUpdate) SetDisableAutoCloseSession

func (f *FindOneAndUpdate) SetDisableAutoCloseSession(b bool) *FindOneAndUpdate

SetDisableAutoCloseSession creates a new DisableAutoCloseSession instance.

func (*FindOneAndUpdate) SetDisableAutoRollbackSession added in v1.2.1

func (f *FindOneAndUpdate) SetDisableAutoRollbackSession(b bool) *FindOneAndUpdate

SetDisableAutoRollbackSession creates a new DisableAutoRollbackSession instance.

func (*FindOneAndUpdate) SetForceRecreateSession

func (f *FindOneAndUpdate) SetForceRecreateSession(b bool) *FindOneAndUpdate

SetForceRecreateSession sets value for the ForceRecreateSession field.

func (*FindOneAndUpdate) SetHint

func (f *FindOneAndUpdate) SetHint(v any) *FindOneAndUpdate

SetHint sets value for the Hint field.

func (*FindOneAndUpdate) SetLet

func (f *FindOneAndUpdate) SetLet(v any) *FindOneAndUpdate

SetLet sets value for the Let field.

func (*FindOneAndUpdate) SetMaxTime

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

SetMaxTime creates a new MaxTime instance.

func (*FindOneAndUpdate) SetProjection

func (f *FindOneAndUpdate) SetProjection(v any) *FindOneAndUpdate

SetProjection creates a new Projection instance.

func (*FindOneAndUpdate) SetReturnDocument

func (f *FindOneAndUpdate) SetReturnDocument(r ReturnDocument) *FindOneAndUpdate

SetReturnDocument creates a new ReturnDocument instance.

func (*FindOneAndUpdate) SetSort

func (f *FindOneAndUpdate) SetSort(i any) *FindOneAndUpdate

SetSort creates a new Sort instance.

func (*FindOneAndUpdate) SetUpsert

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

SetUpsert creates a new Upsert instance.

type FindOneById

type FindOneById struct {
	// If true, an operation on a sharded cluster can return partial results if some shards are down rather than
	// returning an error. The default value is false.
	AllowPartialResults *bool
	// Collation Specifies a collation to use for string comparisons during the operation. This option is only valid
	// for MongoDB  versions >= 3.4. For previous server versions, the driver will return an error if this option is
	// used. The default value is nil, which means the default collation of the collection will be used.
	Collation *Collation
	// A string that will be included in server logs, profiling logs, and currentOp queries to help trace the operation.
	// The default is nil, which means that no comment will be included in the logs.
	Comment *string
	// The index to use for the aggregation. This should either be the index name as a string or the index specification
	// as a document. The driver will return an error if the hint parameter is a multi-key map. The default value is nil,
	// which means that no hint will be sent.
	Hint any
	// A document specifying the exclusive upper bound for a specific index. The default value is nil, which means that
	// there is no maximum value.
	Max any
	// MaxTime The maximum amount of time that the query can run on the server. The default value is nil, meaning that
	// there is no time limit for query execution.
	//
	// NOTE: MaxTime will be deprecated in a future release. The more general Timeout option may be used in
	// its place to control the amount of time that a single operation can run before returning an error. MaxTime is
	// ignored if Timeout is set on the client.
	MaxTime *time.Duration
	// A document specifying the inclusive lower bound for a specific index. The default value is 0, which means that
	// there is no minimum value.
	Min any
	// A document describing which fields will be included in the document returned by the operation. The default value
	// is nil, which means all fields will be included.
	Projection any
	// If true, the document returned by the operation will only contain fields corresponding to the index used. The
	// default value is false.
	ReturnKey *bool
	// If true, a $recordId field with a record identifier will be included in the document returned by the operation.
	// The default value is false.
	ShowRecordID *bool
}

FindOneById represents options that can be used to configure a 'FindOneById' operation.

func MergeFindOneByIdByParams added in v1.1.2

func MergeFindOneByIdByParams(opts []*FindOneById) *FindOneById

MergeFindOneByIdByParams assembles the FindOneById object from optional parameters.

func NewFindOneById

func NewFindOneById() *FindOneById

NewFindOneById creates a new FindOneById instance.

func (*FindOneById) SetAllowPartialResults

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

SetAllowPartialResults creates a new AllowPartialResults instance.

func (*FindOneById) SetCollation

func (f *FindOneById) SetCollation(c *Collation) *FindOneById

SetCollation creates a new Collation instance.

func (*FindOneById) SetComment

func (f *FindOneById) SetComment(s string) *FindOneById

SetComment creates a new Comment instance.

func (*FindOneById) SetHint

func (f *FindOneById) SetHint(v any) *FindOneById

SetHint creates a new Hint instance.

func (*FindOneById) SetMax

func (f *FindOneById) SetMax(v any) *FindOneById

SetMax creates a new Max instance.

func (*FindOneById) SetMaxTime

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

SetMaxTime creates a new MaxTime instance.

func (*FindOneById) SetMin

func (f *FindOneById) SetMin(v any) *FindOneById

SetMin creates a new Min instance.

func (*FindOneById) SetProjection

func (f *FindOneById) SetProjection(v any) *FindOneById

SetProjection creates a new Projection instance.

func (*FindOneById) SetReturnKey

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

SetReturnKey creates a new ReturnKey instance.

func (*FindOneById) SetShowRecordID

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

SetShowRecordID creates a new ShowRecordID instance.

type FindPageable

type FindPageable struct {
	// AllowDiskUse specifies whether the server can write temporary data to disk while executing the Find operation.
	// This option is only valid for MongoDB versions >= 4.4. Server versions >= 3.2 will report an error if this option
	// is specified. For server versions < 3.2, the driver will return a client-side error if this option is specified.
	// The default value is false.
	AllowDiskUse *bool
	// AllowPartial results specifies whether the Find operation on a sharded cluster can return partial results if some
	// shards are down rather than returning an error. The default value is false.
	AllowPartialResults *bool
	// BatchSize is the maximum number of documents to be included in each batch returned by the server.
	BatchSize *int32
	// Collation Specifies a collation to use for string comparisons during the operation. This option is only valid
	// for MongoDB  versions >= 3.4. For previous server versions, the driver will return an error if this option is
	// used. The default value is nil, which means the default collation of the collection will be used.
	Collation *Collation
	// A string that will be included in server logs, profiling logs, and currentOp queries to help trace the operation.
	// The default is nil, which means that no comment will be included in the logs.
	Comment *string
	// CursorType specifies the type of cursor that should be created for the operation. The default is NonTailable, which
	// means that the cursor will be closed by the server when the last batch of documents is retrieved.
	CursorType *CursorType
	// Hint is the index to use for the Find operation. This should either be the index name as a string or the index
	// specification as a document. The driver will return an error if the hint parameter is a multi-key map. The default
	// value is nil, which means that no hint will be sent.
	Hint any
	// Max is a document specifying the exclusive upper bound for a specific index. The default value is nil, which means that
	// there is no maximum value.
	Max any
	// MaxAwaitTime is the maximum amount of time that the server should wait for new documents to satisfy a tailable cursor
	// query. This option is only valid for tailable await cursors (see the CursorType option for more information) and
	// MongoDB versions >= 3.2. For other cursor types or previous server versions, this option is ignored.
	MaxAwaitTime *time.Duration
	// MaxTime The maximum amount of time that the query can run on the server. The default value is nil, meaning that
	// there is no time limit for query execution.
	//
	// NOTE: MaxTime will be deprecated in a future release. The more general Timeout option may be used in
	// its place to control the amount of time that a single operation can run before returning an error. MaxTime is
	// ignored if Timeout is set on the client.
	MaxTime *time.Duration
	// Min is a document specifying the inclusive lower bound for a specific index. The default value is 0, which means that
	// there is no minimum value.
	Min any
	// NoCursorTimeout specifies whether the cursor created by the operation will not time out after a period of inactivity.
	// The default value is false.
	NoCursorTimeout *bool
	// Project is a document describing which fields will be included in the documents returned by the Find operation. The
	// default value is nil, which means all fields will be included.
	Projection any
	// ReturnKey specifies whether the documents returned by the Find operation will only contain fields corresponding to the
	// index used. The default value is false.
	ReturnKey *bool
	// ShowRecordID specifies whether a $recordId field with a record identifier will be included in the documents returned by
	// the Find operation. The default value is false.
	ShowRecordID *bool
	// Let specifies parameters for the find expression. This option is only valid for MongoDB versions >= 5.0. Older
	// servers will report an error for using this option. This must be a document mapping parameter names to values.
	// Values must be constant or closed expressions that do not reference document fields. Parameters can then be
	// accessed as variables in an aggregate expression context (e.g. "$$var").
	Let any
}

FindPageable represents options that can be used to configure a 'FindPageable' operation.

func MergeFindPageableByParams added in v1.1.2

func MergeFindPageableByParams(opts []*FindPageable) *FindPageable

MergeFindPageableByParams assembles the FindPageable object from optional parameters.

func NewFindPageable

func NewFindPageable() *FindPageable

NewFindPageable creates a new FindPageable instance.

func (*FindPageable) SetAllowDiskUse

func (f *FindPageable) SetAllowDiskUse(b bool) *FindPageable

SetAllowDiskUse creates a new AllowDiskUse instance.

func (*FindPageable) SetAllowPartialResults

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

SetAllowPartialResults creates a new AllowPartialResults instance.

func (*FindPageable) SetBatchSize

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

SetBatchSize creates a new BatchSize instance.

func (*FindPageable) SetCollation

func (f *FindPageable) SetCollation(c *Collation) *FindPageable

SetCollation creates a new Collation instance.

func (*FindPageable) SetComment

func (f *FindPageable) SetComment(s string) *FindPageable

SetComment creates a new Comment instance.

func (*FindPageable) SetCursorType

func (f *FindPageable) SetCursorType(c CursorType) *FindPageable

SetCursorType creates a new CursorType instance.

func (*FindPageable) SetHint

func (f *FindPageable) SetHint(v any) *FindPageable

SetHint creates a new Hint instance.

func (*FindPageable) SetLet

func (f *FindPageable) SetLet(v any) *FindPageable

SetLet creates a new Let instance.

func (*FindPageable) SetMax

func (f *FindPageable) SetMax(v any) *FindPageable

SetMax creates a new Max instance.

func (*FindPageable) SetMaxAwaitTime

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

SetMaxAwaitTime creates a new MaxAwaitTime instance.

func (*FindPageable) SetMaxTime

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

SetMaxTime creates a new MaxTime instance.

func (*FindPageable) SetMin

func (f *FindPageable) SetMin(v any) *FindPageable

SetMin creates a new Min instance.

func (*FindPageable) SetNoCursorTimeout

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

SetNoCursorTimeout creates a new NoCursorTimeout instance.

func (*FindPageable) SetProjection

func (f *FindPageable) SetProjection(v any) *FindPageable

SetProjection creates a new Projection instance.

func (*FindPageable) SetReturnKey

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

SetReturnKey creates a new ReturnKey instance.

func (*FindPageable) SetShowRecordID

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

SetShowRecordID creates a new ShowRecordID instance.

type FullDocument

type FullDocument string

FullDocument specifies how a Change stream should return the modified document.

const (
	// FullDocumentDefault does not include a document copy.
	FullDocumentDefault FullDocument = "default"
	// FullDocumentOff is the same as sending no value for fullDocumentBeforeChange.
	FullDocumentOff FullDocument = "off"
	// FullDocumentRequired is the same as WhenAvailable but raises a server-side error if the post-image is not available.
	FullDocumentRequired FullDocument = "required"
	// FullDocumentUpdateLookup includes a delta describing the changes to the document and a copy of the entire document that
	// was changed.
	FullDocumentUpdateLookup FullDocument = "updateLookup"
	// FullDocumentWhenAvailable includes a post-image of the modified document for replace and update Change events
	// if the post-image for this event is available.
	FullDocumentWhenAvailable FullDocument = "whenAvailable"
)

type Global added in v1.2.1

type Global struct {
	// BypassDocumentValidation If true, writes executed as part of the operation will opt out of document-level
	// validation on the server. This option is valid for MongoDB versions >= 3.2 and is ignored for previous server
	// versions. The default value is false.
	// See https://www.mongodb.com/docs/manual/core/schema-validation/ for more information about document validation.
	BypassDocumentValidation bool
	// Comment A string or document that will be included in server logs, profiling logs, and currentOp queries to help
	// trace the operation.  The default value is nil, which means that no comment will be included in the logs.
	Comment any
	// DisableAutoRollbackSession disable auto rollback if an error occurs.
	DisableAutoRollbackSession bool
	// DisableAutoCloseSession Disable automatic closing session, if true, we automatically close session according to
	// the result, if an error occurs, we abort the transaction, otherwise, we commit the transaction.
	// default is false
	DisableAutoCloseSession bool
	// ForceRecreateSession Force the creation of the session, if any session is still open, we close it automatically,
	// aborting all open transactions, and continue creating a new session.
	// default is false
	ForceRecreateSession bool
}

Global represents options that can be used for all operations as a default form, it is important to highlight that it will not overwrite operation options.

type Index

type Index struct {
	// ExpireAfterSeconds The length of time, in seconds, for documents to remain in the collection. The default value
	// is 0, which means that documents will remain in the collection until they're explicitly deleted or the collection
	// is dropped.
	ExpireAfterSeconds *int32
	// Name The name of the index. The default value is "[field1]_[direction1]_[field2]_[direction2]...". For example, an
	// index with the specification {name: 1, age: -1} will be named "name_1_age_-1".
	Name *string
	// Sparse If true, the index will only reference documents that contain the fields specified in the index.
	// The default is false.
	Sparse *bool
	// StorageEngine Specifies the storage engine to use for the index. The value must be a document in the form
	// {<storage engine name>: <options>}. The default value is nil, which means that the default storage engine
	// will be used. This option is only applicable for MongoDB versions >= 3.0 and is ignored for previous server
	// versions.
	StorageEngine any
	// Unique If true, the collection will not accept insertion or update of documents where the index key value matches an
	// existing value in the index. The default is false.
	Unique *bool
	// Version The index version number, either 0 or 1.
	Version *int32
	// DefaultLanguage The language that determines the list of stop words and the rules for the stemmer and tokenizer.
	// This option is only applicable for text indexes and is ignored for other index types. The default value is "english".
	DefaultLanguage *string
	// LanguageOverride The name of the field in the collection's documents that contains the override language for the
	// document. This option is only applicable for text indexes and is ignored for other index types. The default value
	// is the value of the DefaultLanguage option.
	LanguageOverride *string
	// TextVersion The index version number for a text index.
	// See https://www.mongodb.com/docs/manual/core/index-text/#text-versions for information about different version numbers.
	TextVersion *int32
	// Weights A document that contains field and weight pairs. The weight is an integer ranging from 1 to 99,999, inclusive,
	// indicating the significance of the field relative to the other indexed fields in terms of the score. This option
	// is only applicable for text indexes and is ignored for other index types. The default value is nil, which means
	// that every field will have a weight of 1.
	Weights any
	// SphereVersion The index version number for a 2D sphere index.
	// See https://www.mongodb.com/docs/manual/core/2dsphere/#dsphere-v2 for information about different version numbers.
	SphereVersion *int32
	// Bits The precision of the stored geo hash value of the location data. This option only applies to 2D indexes and
	// is ignored for other index types. The value must be between 1 and 32, inclusive. The default value is 26.
	Bits *int32
	// Max The upper inclusive boundary for longitude and latitude values. This option is only applicable to 2D indexes
	// and is ignored for other index types. The default value is 180.0.
	Max *float64
	// Min The lower inclusive boundary for longitude and latitude values. This option is only applicable to 2D indexes
	// and is ignored for other index types. The default value is -180.0.
	Min *float64
	// BucketSize The number of units within which to group location values. Location values that are within BucketSize
	// units of each other will be grouped in the same bucket. This option is only applicable to geoHaystack indexes and is
	// ignored for other index types. The value must be greater than 0.
	BucketSize *int32
	// PartialFilterExpression A document that defines which collection documents the index should reference.
	// This option is only valid for MongoDB versions >= 3.2 and is ignored for previous server versions.
	PartialFilterExpression any
	// Collation Specifies a collation to use for string comparisons during the operation. This option is only valid
	// for MongoDB  versions >= 3.4. For previous server versions, the driver will return an error if this option is
	// used. The default value is nil, which means the default collation of the collection will be used.
	Collation *Collation
	// WildcardProjection A document that defines the wildcard projection for the index.
	WildcardProjection any
	// Hidden If true, the index will exist on the target collection but will not be used by the query planner
	// when executing operations. This option is only valid for MongoDB versions >= 4.4. The default value is false.
	Hidden *bool
}

Index represents options that can be used to configure a CreateOneIndex and CreateManyIndex operation.

func NewIndex

func NewIndex() *Index

NewIndex creates a new Index instance.

func (*Index) SetBits

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

SetBits sets the value for the Bits field.

func (*Index) SetBucketSize

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

SetBucketSize sets the value for the BucketSize field

func (*Index) SetCollation

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

SetCollation sets the value for the Collation field.

func (*Index) SetDefaultLanguage

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

SetDefaultLanguage sets the value for the DefaultLanguage field.

func (*Index) SetExpireAfterSeconds

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

SetExpireAfterSeconds sets value for the ExpireAfterSeconds field.

func (*Index) SetHidden

func (i *Index) SetHidden(hidden bool) *Index

SetHidden sets the value for the Hidden field.

func (*Index) SetLanguageOverride

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

SetLanguageOverride sets the value of the LanguageOverride field.

func (*Index) SetMax

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

SetMax sets the value for the Max field.

func (*Index) SetMin

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

SetMin sets the value for the Min field.

func (*Index) SetName

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

SetName sets the value for the Name field.

func (*Index) SetPartialFilterExpression

func (i *Index) SetPartialFilterExpression(expression any) *Index

SetPartialFilterExpression sets the value for the PartialFilterExpression field.

func (*Index) SetSparse

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

SetSparse sets the value of the Sparse field.

func (*Index) SetSphereVersion

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

SetSphereVersion sets the value for the SphereVersion field.

func (*Index) SetStorageEngine

func (i *Index) SetStorageEngine(engine any) *Index

SetStorageEngine sets the value for the StorageEngine field.

func (*Index) SetTextVersion

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

SetTextVersion sets the value for the TextVersion field.

func (*Index) SetUnique

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

SetUnique sets the value for the Unique field.

func (*Index) SetVersion

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

SetVersion sets the value for the Version field.

func (*Index) SetWeights

func (i *Index) SetWeights(weights any) *Index

SetWeights sets the value for the Weights field.

func (*Index) SetWildcardProjection

func (i *Index) SetWildcardProjection(wildcardProjection any) *Index

SetWildcardProjection sets the value for the WildcardProjection field.

type InsertMany

type InsertMany struct {
	// BypassDocumentValidation If true, writes executed as part of the operation will opt out of document-level
	// validation on the server. This option is valid for MongoDB versions >= 3.2 and is ignored for previous server
	// versions. The default value is false.
	// See https://www.mongodb.com/docs/manual/core/schema-validation/ for more information about document validation.
	BypassDocumentValidation *bool
	// Comment A string or document that will be included in server logs, profiling logs, and currentOp queries to help trace
	// the operation.  The default value is nil, which means that no comment will be included in the logs.
	Comment any
	// DisableAutoRollbackSession disable auto rollback if an error occurs.
	DisableAutoRollbackSession *bool
	// DisableAutoCloseSession Disable automatic closing session, if true, we automatically close session according to
	// the result, if an error occurs, we abort the transaction, otherwise, we commit the transaction.
	// default is false
	DisableAutoCloseSession *bool
	// ForceRecreateSession Force the creation of the session, if any session is still open, we close it automatically,
	// committing the transactions, and continue creating a new session.
	// default is false
	ForceRecreateSession *bool
}

InsertMany represents options that can be used to configure a 'InsertMany' operation.

func MergeInsertManyByParams added in v1.1.2

func MergeInsertManyByParams(opts []*InsertMany, global *Global) *InsertMany

MergeInsertManyByParams assembles the InsertMany object from optional parameters.

func NewInsertMany

func NewInsertMany() *InsertMany

NewInsertMany creates a new InsertMany instance.

func (*InsertMany) SetBypassDocumentValidation

func (i *InsertMany) SetBypassDocumentValidation(b bool) *InsertMany

SetBypassDocumentValidation sets value for the BypassDocumentValidation field.

func (*InsertMany) SetComment

func (i *InsertMany) SetComment(a any) *InsertMany

SetComment sets value for the Comment field.

func (*InsertMany) SetDisableAutoCloseSession

func (i *InsertMany) SetDisableAutoCloseSession(b bool) *InsertMany

SetDisableAutoCloseSession creates a new DisableAutoCloseSession instance.

func (*InsertMany) SetDisableAutoRollback

func (i *InsertMany) SetDisableAutoRollback(b bool) *InsertMany

SetDisableAutoRollback sets value for the DisableAutoRollbackSession field.

func (*InsertMany) SetForceRecreateSession

func (i *InsertMany) SetForceRecreateSession(b bool) *InsertMany

SetForceRecreateSession sets value for the ForceRecreateSession field.

type InsertOne

type InsertOne struct {
	// BypassDocumentValidation If true, writes executed as part of the operation will opt out of document-level
	// validation on the server. This option is valid for MongoDB versions >= 3.2 and is ignored for previous server
	// versions. The default value is false.
	// See https://www.mongodb.com/docs/manual/core/schema-validation/ for more information about document validation.
	BypassDocumentValidation *bool
	// Comment A string or document that will be included in server logs, profiling logs, and currentOp queries to help
	// trace the operation.  The default value is nil, which means that no comment will be included in the logs.
	Comment any
	// DisableAutoRollbackSession disable auto rollback if an error occurs.
	DisableAutoRollbackSession *bool
	// DisableAutoCloseSession Disable automatic closing session, if true, we automatically close session according to
	// the result, if an error occurs, we abort the transaction, otherwise, we commit the transaction.
	// default is false
	DisableAutoCloseSession *bool
	// ForceRecreateSession Force the creation of the session, if any session is still open, we close it automatically,
	// aborting all open transactions, and continue creating a new session.
	// default is false
	ForceRecreateSession *bool
}

InsertOne represents options that can be used to configure a 'InsertOne' operation.

func MergeInsertOneByParams added in v1.1.2

func MergeInsertOneByParams(opts []*InsertOne, global *Global) *InsertOne

MergeInsertOneByParams assembles the InsertOne object from optional parameters.

func NewInsertOne

func NewInsertOne() *InsertOne

NewInsertOne creates a new InsertOne instance.

func (*InsertOne) SetBypassDocumentValidation

func (i *InsertOne) SetBypassDocumentValidation(b bool) *InsertOne

SetBypassDocumentValidation sets value for the BypassDocumentValidation field.

func (*InsertOne) SetComment

func (i *InsertOne) SetComment(a any) *InsertOne

SetComment sets value for the Comment field.

func (*InsertOne) SetDisableAutoCloseSession

func (i *InsertOne) SetDisableAutoCloseSession(b bool) *InsertOne

SetDisableAutoCloseSession creates a new DisableAutoCloseSession instance.

func (*InsertOne) SetDisableAutoRollbackSession added in v1.2.1

func (i *InsertOne) SetDisableAutoRollbackSession(b bool) *InsertOne

SetDisableAutoRollbackSession creates a new DisableAutoRollbackSession instance.

func (*InsertOne) SetForceRecreateSession

func (i *InsertOne) SetForceRecreateSession(b bool) *InsertOne

SetForceRecreateSession sets value for the ForceRecreateSession field.

type ListIndexes

type ListIndexes struct {
	// The maximum number of documents to be included in each batch returned by the server.
	BatchSize *int32
	// MaxTime The maximum amount of time that the query can run on the server. The default value is nil, meaning that
	// there is no time limit for query execution.
	//
	// NOTE: MaxTime will be deprecated in a future release. The more general Timeout option may be used in
	// its place to control the amount of time that a single operation can run before returning an error. MaxTime is
	// ignored if Timeout is set on the client.
	MaxTime *time.Duration
}

ListIndexes represents options that can be used to configure a ListIndexes and ListIndexSpecifications operation.

func MergeListIndexesByParams added in v1.1.2

func MergeListIndexesByParams(opts []*ListIndexes) *ListIndexes

MergeListIndexesByParams assembles the ListIndexes object from optional parameters.

func NewListIndexes

func NewListIndexes() *ListIndexes

NewListIndexes creates a new ListIndexes instance.

func (*ListIndexes) SetBatchSize

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

SetBatchSize creates a new BatchSize instance.

func (*ListIndexes) SetMaxTime

func (l *ListIndexes) SetMaxTime(duration time.Duration) *ListIndexes

SetMaxTime creates a new MaxTime instance.

type Replace

type Replace struct {
	// BypassDocumentValidation If true, writes executed as part of the operation will opt out of document-level
	// validation on the server. This option is valid for MongoDB versions >= 3.2 and is ignored for previous server
	// versions. The default value is false.
	// See https://www.mongodb.com/docs/manual/core/schema-validation/ for more information about document validation.
	BypassDocumentValidation *bool
	// Collation Specifies a collation to use for string comparisons during the operation. This option is only valid
	// for MongoDB  versions >= 3.4. For previous server versions, the driver will return an error if this option is
	// used. The default value is nil, which means the default collation of the collection will be used.
	Collation *Collation
	// Comment A string or document that will be included in server logs, profiling logs, and currentOp queries to help trace
	// the operation.  The default value is nil, which means that no comment will be included in the logs.
	Comment any
	// Hint The index to use for the operation. This should either be the index name as a string or the index specification
	// as a document. This option is only valid for MongoDB versions >= 4.2. Server versions >= 3.4 will return an error
	// if this option is specified. For server versions < 3.4, the driver will return a client-side error if this option
	// is specified. The driver will return an error if this option is specified during an unacknowledged write
	// operation. The driver will return an error if the hint parameter is a multi-key map. The default value is nil,
	// which means that no hint will be sent.
	Hint any
	// Upsert If true, a new document will be inserted if the filter does not match any documents in the collection. The
	// default value is false.
	Upsert *bool
	// Let Specifies parameters for the update expression. This option is only valid for MongoDB versions >= 5.0. Older
	// servers will report an error for using this option. This must be a document mapping parameter names to values.
	// Values must be constant or closed expressions that do not reference document fields. Parameters can then be
	// accessed as variables in an aggregate expression context (e.g. "$$var").
	Let any
	// DisableAutoRollbackSession disable auto rollback if an error occurs.
	DisableAutoRollbackSession *bool
	// DisableAutoCloseSession Disable automatic closing session, if true, we automatically close session according to
	// the result, if an error occurs, we abort the transaction, otherwise, we commit the transaction.
	// default is false
	DisableAutoCloseSession *bool
	// ForceRecreateSession Force the creation of the session, if any session is still open, we close it automatically,
	// committing the transactions, and continue creating a new session.
	// default is false
	ForceRecreateSession *bool
}

Replace represents options that can be used to configure a 'ReplaceOne' operation.

func MergeReplaceByParams added in v1.1.2

func MergeReplaceByParams(opts []*Replace, global *Global) *Replace

MergeReplaceByParams assembles the Replace object from optional parameters.

func NewReplace

func NewReplace() *Replace

NewReplace creates a new Replace instance.

func (*Replace) SetBypassDocumentValidation

func (r *Replace) SetBypassDocumentValidation(b bool) *Replace

SetBypassDocumentValidation sets value for the BypassDocumentValidation field.

func (*Replace) SetCollation

func (r *Replace) SetCollation(c *Collation) *Replace

SetCollation sets value for the Collation field.

func (*Replace) SetComment

func (r *Replace) SetComment(a any) *Replace

SetComment sets value for the Comment field.

func (*Replace) SetDisableAutoCloseSession

func (r *Replace) SetDisableAutoCloseSession(b bool) *Replace

SetDisableAutoCloseSession creates a new DisableAutoCloseSession instance.

func (*Replace) SetDisableAutoRollbackSession added in v1.2.1

func (r *Replace) SetDisableAutoRollbackSession(b bool) *Replace

SetDisableAutoRollbackSession creates a new DisableAutoRollbackSession instance.

func (*Replace) SetForceRecreateSession

func (r *Replace) SetForceRecreateSession(b bool) *Replace

SetForceRecreateSession sets value for the ForceRecreateSession field.

func (*Replace) SetHint

func (r *Replace) SetHint(a any) *Replace

SetHint sets value for the Hint field.

func (*Replace) SetLet

func (r *Replace) SetLet(a any) *Replace

SetLet sets value for the Let field.

type ReturnDocument

type ReturnDocument int8

ReturnDocument specifies whether a findAndUpdate operation should return the document as it was before the update or as it is after the update.

const (
	// ReturnDocumentBefore specifies that findAndUpdate should return the document as it was before the update.
	ReturnDocumentBefore ReturnDocument = iota
	// ReturnDocumentAfter specifies that findAndUpdate should return the document as it is after the update.
	ReturnDocumentAfter
)

type Update

type Update struct {
	// ArrayFilters A set of filters specifying to which array elements an update should apply. This option is only valid for MongoDB
	// versions >= 3.6. For previous server versions, the driver will return an error if this option is used. The
	// default value is nil, which means the update will apply to all array elements.
	ArrayFilters *ArrayFilters
	// BypassDocumentValidation If true, writes executed as part of the operation will opt out of document-level
	// validation on the server. This option is valid for MongoDB versions >= 3.2 and is ignored for previous server
	// versions. The default value is false.
	// See https://www.mongodb.com/docs/manual/core/schema-validation/ for more information about document validation.
	BypassDocumentValidation *bool
	// Collation Specifies a collation to use for string comparisons during the operation. This option is only valid
	// for MongoDB  versions >= 3.4. For previous server versions, the driver will return an error if this option is
	// used. The default value is nil, which means the default collation of the collection will be used.
	Collation *Collation
	// Comment A string or document that will be included in server logs, profiling logs, and currentOp queries to help trace
	// the operation.  The default value is nil, which means that no comment will be included in the logs.
	Comment any
	// Hint The index to use for the operation. This should either be the index name as a string or the index specification
	// as a document. This option is only valid for MongoDB versions >= 4.2. Server versions >= 3.4 will return an error
	// if this option is specified. For server versions < 3.4, the driver will return a client-side error if this option
	// is specified. The driver will return an error if this option is specified during an unacknowledged write
	// operation. The driver will return an error if the hint parameter is a multi-key map. The default value is nil,
	// which means that no hint will be sent.
	Hint any
	// Upsert If true, a new document will be inserted if the filter does not match any documents in the collection. The
	// default value is false.
	Upsert *bool
	// Let Specifies parameters for the update expression. This option is only valid for MongoDB versions >= 5.0. Older
	// servers will report an error for using this option. This must be a document mapping parameter names to values.
	// Values must be constant or closed expressions that do not reference document fields. Parameters can then be
	// accessed as variables in an aggregate expression context (e.g. "$$var").
	Let any
	// DisableAutoRollbackSession disable auto rollback if an error occurs.
	DisableAutoRollbackSession *bool
	// DisableAutoCloseSession Disable automatic closing session, if true, we automatically close session according to
	// the result, if an error occurs, we abort the transaction, otherwise, we commit the transaction.
	// default is false
	DisableAutoCloseSession *bool
	// ForceRecreateSession Force the creation of the session, if any session is still open, we close it automatically,
	// committing the transactions, and continue creating a new session.
	// default is false
	ForceRecreateSession *bool
}

Update represents options that can be used to configure a 'UpdateOne' ,'UpdateMany' or 'UpdateOneById' operation.

func MergeUpdateByParams added in v1.1.2

func MergeUpdateByParams(opts []*Update, global *Global) *Update

MergeUpdateByParams assembles the Update object from optional parameters.

func NewUpdate

func NewUpdate() *Update

NewUpdate creates a new Update instance.

func (*Update) SetArrayFilters

func (u *Update) SetArrayFilters(a *ArrayFilters) *Update

SetArrayFilters sets value for the ArrayFilters field.

func (*Update) SetBypassDocumentValidation

func (u *Update) SetBypassDocumentValidation(b bool) *Update

SetBypassDocumentValidation sets value for the BypassDocumentValidation field.

func (*Update) SetCollation

func (u *Update) SetCollation(c *Collation) *Update

SetCollation sets value for the Collation field.

func (*Update) SetComment

func (u *Update) SetComment(a any) *Update

SetComment sets value for the Comment field.

func (*Update) SetDisableAutoCloseSession

func (u *Update) SetDisableAutoCloseSession(b bool) *Update

SetDisableAutoCloseSession creates a new DisableAutoCloseSession instance.

func (*Update) SetDisableAutoRollbackSession added in v1.2.1

func (u *Update) SetDisableAutoRollbackSession(b bool) *Update

SetDisableAutoRollbackSession creates a new DisableAutoRollbackSession instance.

func (*Update) SetForceRecreateSession

func (u *Update) SetForceRecreateSession(b bool) *Update

SetForceRecreateSession sets value for the ForceRecreateSession field.

func (*Update) SetHint

func (u *Update) SetHint(a any) *Update

SetHint sets value for the Hint field.

func (*Update) SetLet

func (u *Update) SetLet(a any) *Update

SetLet sets value for the Let field.

func (*Update) SetUpsert

func (u *Update) SetUpsert(b bool) *Update

SetUpsert creates a new Upsert instance.

type Watch

type Watch struct {
	// DatabaseName database name to watch
	DatabaseName string
	// CollectionName collection name to watch
	CollectionName string
	// BatchSize The maximum number of documents to be included in each batch returned by the server.
	BatchSize *int32
	// Collation Specifies a collation to use for string comparisons during the operation. This option is only valid
	// for MongoDB  versions >= 3.4. For previous server versions, the driver will return an error if this option is
	// used. The default value is nil, which means the default collation of the collection will be used.
	Collation *Collation
	// Comment A string that will be included in server logs, profiling logs, and currentOp queries to help trace the operation.
	// The default is nil, which means that no comment will be included in the logs.
	Comment *string
	// FullDocument Specifies how the updated document should be returned in Change notifications for update operations.
	// The default is FullDocumentDefault, which means that only partial update deltas will be included in the Change
	// notification.
	FullDocument *FullDocument
	// FullDocumentBeforeChange Specifies how the pre-update document should be returned in Change notifications for
	// update operations. The default is FullDocumentOff, which means that the pre-update document will not be included
	// in the Change notification.
	FullDocumentBeforeChange *FullDocument
	// MaxAwaitTime The maximum amount of time that the server should wait for new documents to satisfy a tailable cursor query.
	MaxAwaitTime *time.Duration
	// ResumeAfter A document specifying the logical starting point for the Change stream. Only changes corresponding to an oplog
	// entry immediately after the resume token will be returned. If this is specified, StartAtOperationTime and
	// StartAfter must not be set.
	ResumeAfter any
	// ShowExpandedEvents specifies whether the server will return an expanded list of Change stream events. Additional
	// events include: createIndexes, dropIndexes, modify, create, shardCollection, reshardCollection and
	// refineCollectionShardKey. This option is only valid for MongoDB versions >= 6.0.
	ShowExpandedEvents *bool
	// StartAtOperationTime If specified, the Change stream will only return changes that occurred at or after the given timestamp. This
	// option is only valid for MongoDB versions >= 4.0. If this is specified, ResumeAfter and StartAfter must not be
	// set.
	StartAtOperationTime *primitive.Timestamp
	// StartAfter A document specifying the logical starting point for the Change stream. This is similar to the ResumeAfter
	// option, but allows a resume token from an "invalidate" notification to be used. This allows a Change stream on a
	// collection to be resumed after the collection has been dropped and recreated or renamed. Only changes
	// corresponding to an oplog entry immediately after the specified token will be returned. If this is specified,
	// ResumeAfter and StartAtOperationTime must not be set. This option is only valid for MongoDB versions >= 4.1.1.
	StartAfter any
	// Custom options to be added to the initial aggregate for the Change stream. Key-value pairs of the BSON map should
	// correlate with desired option names and values. Values must be Marshalable. Custom options may conflict with
	// non-custom options, and custom options bypass client-side validation. Prefer using non-custom options where possible.
	Custom bson.M
	// CustomPipeline options to be added to the $changeStream stage in the initial aggregate. Key-value pairs of the BSON map should
	// correlate with desired option names and values. Values must be Marshalable. Custom pipeline options bypass client-side
	// validation. Prefer using non-custom options where possible.
	CustomPipeline bson.M
}

Watch represents options that can be used to configure a 'Watch' operation.

func MergeWatchByParams added in v1.1.2

func MergeWatchByParams(opts []*Watch) *Watch

MergeWatchByParams assembles the Watch object from optional parameters.

func NewWatch

func NewWatch() *Watch

NewWatch creates a new Watch instance.

func (*Watch) SetBatchSize

func (w *Watch) SetBatchSize(i int32) *Watch

SetBatchSize creates a new BatchSize instance.

func (*Watch) SetCollation

func (w *Watch) SetCollation(c *Collation) *Watch

SetCollation sets value for the Collation field.

func (*Watch) SetCollectionName

func (w *Watch) SetCollectionName(s string) *Watch

SetCollectionName creates a new CollectionName instance.

func (*Watch) SetComment

func (w *Watch) SetComment(s string) *Watch

SetComment sets value for the Comment field.

func (*Watch) SetCustom

func (w *Watch) SetCustom(b bson.M) *Watch

SetCustom sets value for the Custom field.

func (*Watch) SetCustomPipeline

func (w *Watch) SetCustomPipeline(b bson.M) *Watch

SetCustomPipeline sets value for the CustomPipeline field.

func (*Watch) SetDatabaseName

func (w *Watch) SetDatabaseName(s string) *Watch

SetDatabaseName creates a new DatabaseName instance.

func (*Watch) SetFullDocument

func (w *Watch) SetFullDocument(f FullDocument) *Watch

SetFullDocument sets value for the FullDocument field.

func (*Watch) SetFullDocumentBeforeChange

func (w *Watch) SetFullDocumentBeforeChange(f FullDocument) *Watch

SetFullDocumentBeforeChange sets value for the FullDocumentBeforeChange field.

func (*Watch) SetMaxAwaitTime

func (w *Watch) SetMaxAwaitTime(d time.Duration) *Watch

SetMaxAwaitTime sets value for the MaxAwaitTime field.

func (*Watch) SetResumeAfter

func (w *Watch) SetResumeAfter(a any) *Watch

SetResumeAfter sets value for the ResumeAfter field.

func (*Watch) SetShowExpandedEvents

func (w *Watch) SetShowExpandedEvents(b bool) *Watch

SetShowExpandedEvents sets value for the ShowExpandedEvents field.

func (*Watch) SetStartAfter

func (w *Watch) SetStartAfter(a any) *Watch

SetStartAfter sets value for the StartAfter field.

func (*Watch) SetStartAtOperationTime

func (w *Watch) SetStartAtOperationTime(t primitive.Timestamp) *Watch

SetStartAtOperationTime sets value for the StartAtOperationTime field.

type WatchWithHandler added in v1.0.8

type WatchWithHandler struct {
	// DatabaseName database name to watch
	DatabaseName string
	// CollectionName collection name to watch
	CollectionName string
	// ContextFuncTimeout Duration time to process the func watch, timeout applied in the past context.
	//
	// default: 5 seconds
	ContextFuncTimeout time.Duration
	// DelayLoop Delay to run the next search for messages in the queue
	//
	// default: 5 seconds
	DelayLoop time.Duration
	// BatchSize The maximum number of documents to be included in each batch returned by the server.
	BatchSize *int32
	// Collation Specifies a collation to use for string comparisons during the operation. This option is only valid
	// for MongoDB  versions >= 3.4. For previous server versions, the driver will return an error if this option is
	// used. The default value is nil, which means the default collation of the collection will be used.
	Collation *Collation
	// Comment A string that will be included in server logs, profiling logs, and currentOp queries to help trace the operation.
	// The default is nil, which means that no comment will be included in the logs.
	Comment *string
	// FullDocument Specifies how the updated document should be returned in Change notifications for update operations.
	// The default is FullDocumentDefault, which means that only partial update deltas will be included in the Change
	// notification.
	FullDocument *FullDocument
	// FullDocumentBeforeChange Specifies how the pre-update document should be returned in Change notifications for
	// update operations. The default is FullDocumentOff, which means that the pre-update document will not be included
	// in the Change notification.
	FullDocumentBeforeChange *FullDocument
	// MaxAwaitTime The maximum amount of time that the server should wait for new documents to satisfy a tailable cursor query.
	MaxAwaitTime *time.Duration
	// ResumeAfter A document specifying the logical starting point for the Change stream. Only changes corresponding to an oplog
	// entry immediately after the resume token will be returned. If this is specified, StartAtOperationTime and
	// StartAfter must not be set.
	ResumeAfter any
	// ShowExpandedEvents specifies whether the server will return an expanded list of Change stream events. Additional
	// events include: createIndexes, dropIndexes, modify, create, shardCollection, reshardCollection and
	// refineCollectionShardKey. This option is only valid for MongoDB versions >= 6.0.
	ShowExpandedEvents *bool
	// StartAtOperationTime If specified, the Change stream will only return changes that occurred at or after the given timestamp. This
	// option is only valid for MongoDB versions >= 4.0. If this is specified, ResumeAfter and StartAfter must not be
	// set.
	StartAtOperationTime *primitive.Timestamp
	// StartAfter A document specifying the logical starting point for the Change stream. This is similar to the ResumeAfter
	// option, but allows a resume token from an "invalidate" notification to be used. This allows a Change stream on a
	// collection to be resumed after the collection has been dropped and recreated or renamed. Only changes
	// corresponding to an oplog entry immediately after the specified token will be returned. If this is specified,
	// ResumeAfter and StartAtOperationTime must not be set. This option is only valid for MongoDB versions >= 4.1.1.
	StartAfter any
	// Custom options to be added to the initial aggregate for the Change stream. Key-value pairs of the BSON map should
	// correlate with desired option names and values. Values must be Marshalable. Custom options may conflict with
	// non-custom options, and custom options bypass client-side validation. Prefer using non-custom options where possible.
	Custom bson.M
	// CustomPipeline options to be added to the $changeStream stage in the initial aggregate. Key-value pairs of the BSON map should
	// correlate with desired option names and values. Values must be Marshalable. Custom pipeline options bypass client-side
	// validation. Prefer using non-custom options where possible.
	CustomPipeline bson.M
}

WatchWithHandler represents options that can be used to configure a 'WatchWithHandler' operation.

func MergeWatchHandlerByParams added in v1.1.2

func MergeWatchHandlerByParams(opts []*WatchWithHandler) *WatchWithHandler

MergeWatchHandlerByParams assembles the WatchWithHandler object from optional parameters.

func NewWatchWithHandler added in v1.0.8

func NewWatchWithHandler() *WatchWithHandler

NewWatchWithHandler creates a new WatchWithHandler instance.

func (*WatchWithHandler) SetBatchSize added in v1.0.8

func (w *WatchWithHandler) SetBatchSize(i int32) *WatchWithHandler

SetBatchSize creates a new BatchSize instance.

func (*WatchWithHandler) SetCollation added in v1.0.8

func (w *WatchWithHandler) SetCollation(c *Collation) *WatchWithHandler

SetCollation sets value for the Collation field.

func (*WatchWithHandler) SetCollectionName added in v1.0.8

func (w *WatchWithHandler) SetCollectionName(s string) *WatchWithHandler

SetCollectionName sets value for the WatchWithHandler field.

func (*WatchWithHandler) SetComment added in v1.0.8

func (w *WatchWithHandler) SetComment(s string) *WatchWithHandler

SetComment sets value for the Comment field.

func (*WatchWithHandler) SetContextFuncTimeout added in v1.0.8

func (w *WatchWithHandler) SetContextFuncTimeout(d time.Duration) *WatchWithHandler

func (*WatchWithHandler) SetCustom added in v1.0.8

func (w *WatchWithHandler) SetCustom(b bson.M) *WatchWithHandler

SetCustom sets value for the Custom field.

func (*WatchWithHandler) SetCustomPipeline added in v1.0.8

func (w *WatchWithHandler) SetCustomPipeline(b bson.M) *WatchWithHandler

SetCustomPipeline sets value for the CustomPipeline field.

func (*WatchWithHandler) SetDatabaseName added in v1.0.8

func (w *WatchWithHandler) SetDatabaseName(s string) *WatchWithHandler

SetDatabaseName sets value for the DatabaseName field.

func (*WatchWithHandler) SetDelayLoop added in v1.0.8

func (w *WatchWithHandler) SetDelayLoop(d time.Duration) *WatchWithHandler

func (*WatchWithHandler) SetFullDocument added in v1.0.8

func (w *WatchWithHandler) SetFullDocument(f FullDocument) *WatchWithHandler

SetFullDocument sets value for the FullDocument field.

func (*WatchWithHandler) SetFullDocumentBeforeChange added in v1.0.8

func (w *WatchWithHandler) SetFullDocumentBeforeChange(f FullDocument) *WatchWithHandler

SetFullDocumentBeforeChange sets value for the FullDocumentBeforeChange field.

func (*WatchWithHandler) SetMaxAwaitTime added in v1.0.8

func (w *WatchWithHandler) SetMaxAwaitTime(d time.Duration) *WatchWithHandler

SetMaxAwaitTime sets value for the MaxAwaitTime field.

func (*WatchWithHandler) SetResumeAfter added in v1.0.8

func (w *WatchWithHandler) SetResumeAfter(a any) *WatchWithHandler

SetResumeAfter sets value for the ResumeAfter field.

func (*WatchWithHandler) SetShowExpandedEvents added in v1.0.8

func (w *WatchWithHandler) SetShowExpandedEvents(b bool) *WatchWithHandler

SetShowExpandedEvents sets value for the ShowExpandedEvents field.

func (*WatchWithHandler) SetStartAfter added in v1.0.8

func (w *WatchWithHandler) SetStartAfter(a any) *WatchWithHandler

SetStartAfter sets value for the StartAfter field.

func (*WatchWithHandler) SetStartAtOperationTime added in v1.0.8

func (w *WatchWithHandler) SetStartAtOperationTime(t primitive.Timestamp) *WatchWithHandler

SetStartAtOperationTime sets value for the StartAtOperationTime field.

Jump to

Keyboard shortcuts

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