Documentation ¶
Index ¶
- func ParseArrayFiltersMongoOptions(a *ArrayFilters) *options.ArrayFilters
- func ParseCollationMongoOptions(c *Collation) *options.Collation
- func ParseCursorType(c *CursorType) *options.CursorType
- func ParseFullDocument(f *FullDocument) *options.FullDocument
- func ParseReturnDocument(r *ReturnDocument) *options.ReturnDocument
- type Aggregate
- func (a Aggregate) SetAllowDiskUse(b bool) Aggregate
- func (a Aggregate) SetBatchSize(i int32) Aggregate
- func (a Aggregate) SetBypassDocumentValidation(b bool) Aggregate
- func (a Aggregate) SetCollation(c *Collation) Aggregate
- func (a Aggregate) SetComment(s string) Aggregate
- func (a Aggregate) SetCustom(b bson.M) Aggregate
- func (a Aggregate) SetHint(v any) Aggregate
- func (a Aggregate) SetLet(v any) Aggregate
- func (a Aggregate) SetMaxAwaitTime(d time.Duration) Aggregate
- func (a Aggregate) SetMaxTime(d time.Duration) Aggregate
- type ArrayFilters
- type Collation
- type Count
- type CursorType
- type Delete
- type Distinct
- type DropIndex
- type EstimatedDocumentCount
- type Exists
- type Find
- func (f Find) SetAllowDiskUse(b bool) Find
- func (f Find) SetAllowPartialResults(b bool) Find
- func (f Find) SetBatchSize(i int32) Find
- func (f Find) SetCollation(c *Collation) Find
- func (f Find) SetComment(s string) Find
- func (f Find) SetCursorType(c CursorType) Find
- func (f Find) SetHint(v any) Find
- func (f Find) SetLet(v any) Find
- func (f Find) SetLimit(i int64) Find
- func (f Find) SetMax(v any) Find
- func (f Find) SetMaxAwaitTime(d time.Duration) Find
- func (f Find) SetMaxTime(d time.Duration) Find
- func (f Find) SetMin(v any) Find
- func (f Find) SetNoCursorTimeout(b bool) Find
- func (f Find) SetProjection(v any) Find
- func (f Find) SetReturnKey(b bool) Find
- func (f Find) SetShowRecordID(b bool) Find
- func (f Find) SetSkip(i int64) Find
- func (f Find) SetSort(a any) Find
- type FindOne
- func (f FindOne) SetAllowPartialResults(b bool) FindOne
- func (f FindOne) SetCollation(c *Collation) FindOne
- func (f FindOne) SetComment(s string) FindOne
- func (f FindOne) SetHint(v any) FindOne
- func (f FindOne) SetMax(v any) FindOne
- func (f FindOne) SetMaxTime(d time.Duration) FindOne
- func (f FindOne) SetMin(v any) FindOne
- func (f FindOne) SetProjection(v any) FindOne
- func (f FindOne) SetReturnKey(b bool) FindOne
- func (f FindOne) SetShowRecordID(b bool) FindOne
- func (f FindOne) SetSkip(i int64) FindOne
- func (f FindOne) SetSort(a any) FindOne
- type FindOneAndDelete
- func (f FindOneAndDelete) SetCollation(c *Collation) FindOneAndDelete
- func (f FindOneAndDelete) SetComment(s string) FindOneAndDelete
- func (f FindOneAndDelete) SetDisableAutoCloseSession(b bool) FindOneAndDelete
- func (f FindOneAndDelete) SetForceRecreateSession(b bool) FindOneAndDelete
- func (f FindOneAndDelete) SetHint(v any) FindOneAndDelete
- func (f FindOneAndDelete) SetLet(v any) FindOneAndDelete
- func (f FindOneAndDelete) SetMaxTime(d time.Duration) FindOneAndDelete
- func (f FindOneAndDelete) SetProjection(v any) FindOneAndDelete
- func (f FindOneAndDelete) SetSort(a any) FindOneAndDelete
- type FindOneAndReplace
- func (f FindOneAndReplace) SetBypassDocumentValidation(b bool) FindOneAndReplace
- func (f FindOneAndReplace) SetCollation(c *Collation) FindOneAndReplace
- func (f FindOneAndReplace) SetComment(s string) FindOneAndReplace
- func (f FindOneAndReplace) SetDisableAutoCloseSession(b bool) FindOneAndReplace
- func (f FindOneAndReplace) SetForceRecreateSession(b bool) FindOneAndReplace
- func (f FindOneAndReplace) SetHint(v any) FindOneAndReplace
- func (f FindOneAndReplace) SetLet(v any) FindOneAndReplace
- func (f FindOneAndReplace) SetMaxTime(d time.Duration) FindOneAndReplace
- func (f FindOneAndReplace) SetProjection(v any) FindOneAndReplace
- func (f FindOneAndReplace) SetReturnDocument(r ReturnDocument) FindOneAndReplace
- func (f FindOneAndReplace) SetSort(a any) FindOneAndReplace
- func (f FindOneAndReplace) SetUpsert(b bool) FindOneAndReplace
- type FindOneAndUpdate
- func (f FindOneAndUpdate) SetArrayFilters(a *ArrayFilters) FindOneAndUpdate
- func (f FindOneAndUpdate) SetBypassDocumentValidation(b bool) FindOneAndUpdate
- func (f FindOneAndUpdate) SetCollation(c *Collation) FindOneAndUpdate
- func (f FindOneAndUpdate) SetComment(a any) FindOneAndUpdate
- func (f FindOneAndUpdate) SetDisableAutoCloseSession(b bool) FindOneAndUpdate
- func (f FindOneAndUpdate) SetForceRecreateSession(b bool) FindOneAndUpdate
- func (f FindOneAndUpdate) SetHint(v any) FindOneAndUpdate
- func (f FindOneAndUpdate) SetLet(v any) FindOneAndUpdate
- func (f FindOneAndUpdate) SetMaxTime(d time.Duration) FindOneAndUpdate
- func (f FindOneAndUpdate) SetProjection(v any) FindOneAndUpdate
- func (f FindOneAndUpdate) SetReturnDocument(r ReturnDocument) FindOneAndUpdate
- func (f FindOneAndUpdate) SetSort(i any) FindOneAndUpdate
- func (f FindOneAndUpdate) SetUpsert(b bool) FindOneAndUpdate
- type FindOneById
- func (f FindOneById) SetAllowPartialResults(b bool) FindOneById
- func (f FindOneById) SetCollation(c *Collation) FindOneById
- func (f FindOneById) SetComment(s string) FindOneById
- func (f FindOneById) SetHint(v any) FindOneById
- func (f FindOneById) SetMax(v any) FindOneById
- func (f FindOneById) SetMaxTime(d time.Duration) FindOneById
- func (f FindOneById) SetMin(v any) FindOneById
- func (f FindOneById) SetProjection(v any) FindOneById
- func (f FindOneById) SetReturnKey(b bool) FindOneById
- func (f FindOneById) SetShowRecordID(b bool) FindOneById
- type FindPageable
- func (f FindPageable) SetAllowDiskUse(b bool) FindPageable
- func (f FindPageable) SetAllowPartialResults(b bool) FindPageable
- func (f FindPageable) SetBatchSize(i int32) FindPageable
- func (f FindPageable) SetCollation(c *Collation) FindPageable
- func (f FindPageable) SetComment(s string) FindPageable
- func (f FindPageable) SetCursorType(c CursorType) FindPageable
- func (f FindPageable) SetHint(v any) FindPageable
- func (f FindPageable) SetLet(v any) FindPageable
- func (f FindPageable) SetMax(v any) FindPageable
- func (f FindPageable) SetMaxAwaitTime(d time.Duration) FindPageable
- func (f FindPageable) SetMaxTime(d time.Duration) FindPageable
- func (f FindPageable) SetMin(v any) FindPageable
- func (f FindPageable) SetNoCursorTimeout(b bool) FindPageable
- func (f FindPageable) SetProjection(v any) FindPageable
- func (f FindPageable) SetReturnKey(b bool) FindPageable
- func (f FindPageable) SetShowRecordID(b bool) FindPageable
- type FullDocument
- type Index
- func (i Index) SetBits(bits int32) Index
- func (i Index) SetBucketSize(bucketSize int32) Index
- func (i Index) SetCollation(collation *Collation) Index
- func (i Index) SetDefaultLanguage(language string) Index
- func (i Index) SetExpireAfterSeconds(seconds int32) Index
- func (i Index) SetHidden(hidden bool) Index
- func (i Index) SetLanguageOverride(override string) Index
- func (i Index) SetMax(max float64) Index
- func (i Index) SetMin(min float64) Index
- func (i Index) SetName(name string) Index
- func (i Index) SetPartialFilterExpression(expression any) Index
- func (i Index) SetSparse(sparse bool) Index
- func (i Index) SetSphereVersion(version int32) Index
- func (i Index) SetStorageEngine(engine any) Index
- func (i Index) SetTextVersion(version int32) Index
- func (i Index) SetUnique(unique bool) Index
- func (i Index) SetVersion(version int32) Index
- func (i Index) SetWeights(weights any) Index
- func (i Index) SetWildcardProjection(wildcardProjection any) Index
- type InsertMany
- func (i InsertMany) SetBypassDocumentValidation(b bool) InsertMany
- func (i InsertMany) SetComment(a any) InsertMany
- func (i InsertMany) SetDisableAutoCloseSession(b bool) InsertMany
- func (i InsertMany) SetDisableAutoRollback(b bool) InsertMany
- func (i InsertMany) SetForceRecreateSession(b bool) InsertMany
- type InsertOne
- type ListIndexes
- type Replace
- func (r Replace) SetBypassDocumentValidation(b bool) Replace
- func (r Replace) SetCollation(c *Collation) Replace
- func (r Replace) SetComment(a any) Replace
- func (r Replace) SetDisableAutoCloseSession(b bool) Replace
- func (r Replace) SetForceRecreateSession(b bool) Replace
- func (r Replace) SetHint(a any) Replace
- func (r Replace) SetLet(a any) Replace
- type ReturnDocument
- type Update
- func (u Update) SetArrayFilters(a *ArrayFilters) Update
- func (u Update) SetBypassDocumentValidation(b bool) Update
- func (u Update) SetCollation(c *Collation) Update
- func (u Update) SetComment(a any) Update
- func (u Update) SetDisableAutoCloseSession(b bool) Update
- func (u Update) SetForceRecreateSession(b bool) Update
- func (u Update) SetHint(a any) Update
- func (u Update) SetLet(a any) Update
- func (u Update) SetUpsert(b bool) Update
- type Watch
- func (w Watch) SetBatchSize(i int32) Watch
- func (w Watch) SetCollation(c *Collation) Watch
- func (w Watch) SetCollectionName(s string) Watch
- func (w Watch) SetComment(s string) Watch
- func (w Watch) SetCustom(b bson.M) Watch
- func (w Watch) SetCustomPipeline(b bson.M) Watch
- func (w Watch) SetDatabaseName(s string) Watch
- func (w Watch) SetFullDocument(f FullDocument) Watch
- func (w Watch) SetFullDocumentBeforeChange(f FullDocument) Watch
- func (w Watch) SetMaxAwaitTime(d time.Duration) Watch
- func (w Watch) SetResumeAfter(a any) Watch
- func (w Watch) SetShowExpandedEvents(b bool) Watch
- func (w Watch) SetStartAfter(a any) Watch
- func (w Watch) SetStartAtOperationTime(t primitive.Timestamp) Watch
- type WatchWithHandler
- func (w WatchWithHandler) SetBatchSize(i int32) WatchWithHandler
- func (w WatchWithHandler) SetCollation(c *Collation) WatchWithHandler
- func (w WatchWithHandler) SetCollectionName(s string) WatchWithHandler
- func (w WatchWithHandler) SetComment(s string) WatchWithHandler
- func (w WatchWithHandler) SetContextFuncTimeout(d time.Duration) WatchWithHandler
- func (w WatchWithHandler) SetCustom(b bson.M) WatchWithHandler
- func (w WatchWithHandler) SetCustomPipeline(b bson.M) WatchWithHandler
- func (w WatchWithHandler) SetDatabaseName(s string) WatchWithHandler
- func (w WatchWithHandler) SetDelayLoop(d time.Duration) WatchWithHandler
- func (w WatchWithHandler) SetFullDocument(f FullDocument) WatchWithHandler
- func (w WatchWithHandler) SetFullDocumentBeforeChange(f FullDocument) WatchWithHandler
- func (w WatchWithHandler) SetMaxAwaitTime(d time.Duration) WatchWithHandler
- func (w WatchWithHandler) SetResumeAfter(a any) WatchWithHandler
- func (w WatchWithHandler) SetShowExpandedEvents(b bool) WatchWithHandler
- func (w WatchWithHandler) SetStartAfter(a any) WatchWithHandler
- func (w WatchWithHandler) SetStartAtOperationTime(t primitive.Timestamp) WatchWithHandler
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 ¶
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 GetAggregateOptionByParams ¶
GetAggregateOptionByParams assembles the Aggregate object from optional parameters.
func (Aggregate) SetAllowDiskUse ¶
SetAllowDiskUse sets value for the AllowDiskUse field.
func (Aggregate) SetBatchSize ¶
SetBatchSize sets value for the BatchSize field.
func (Aggregate) SetBypassDocumentValidation ¶
SetBypassDocumentValidation sets value for the BypassDocumentValidation field.
func (Aggregate) SetCollation ¶
SetCollation sets value for the Collation field.
func (Aggregate) SetComment ¶
SetComment sets value for the Comment field.
func (Aggregate) SetMaxAwaitTime ¶
SetMaxAwaitTime sets value for the MaxAwaitTime 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 GetCountOptionByParams ¶
GetCountOptionByParams assembles the Count object from optional parameters.
func (Count) SetCollation ¶
SetCollation sets value for the Collation field.
func (Count) SetComment ¶
SetComment sets value for the Comment field.
func (Count) SetMaxTime ¶
SetMaxTime sets value for the MaxTime 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 // 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. 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. ForceRecreateSession bool }
Delete represents options that can be used to configure DeleteOne and DeleteMany operations.
func GetDeleteOptionByParams ¶
GetDeleteOptionByParams assembles the Delete object from optional parameters.
func (Delete) SetCollation ¶
SetCollation sets value for the Collation field.
func (Delete) SetComment ¶
SetComment sets value for the Comment field.
func (Delete) SetDisableAutoCloseSession ¶
SetDisableAutoCloseSession sets value for the DisableAutoCloseSession field.
func (Delete) SetForceRecreateSession ¶
SetForceRecreateSession sets value for the ForceRecreateSession 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 GetDistinctOptionByParams ¶
GetDistinctOptionByParams assembles the Distinct object from optional parameters.
func (Distinct) SetCollation ¶
SetCollation sets value for the Collation field.
func (Distinct) SetComment ¶
SetComment sets value for the Comment 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 GetDropIndexOptionByParams ¶
GetDropIndexOptionByParams assembles the DropIndex object from optional parameters.
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 GetEstimatedDocumentCountOptionByParams ¶
func GetEstimatedDocumentCountOptionByParams(opts []EstimatedDocumentCount) EstimatedDocumentCount
GetEstimatedDocumentCountOptionByParams assembles the EstimatedDocumentCount object from optional parameters.
func NewEstimatedDocumentCount ¶
func NewEstimatedDocumentCount() EstimatedDocumentCount
NewEstimatedDocumentCount creates a new EstimatedDocumentCount instance.
func (EstimatedDocumentCount) SetComment ¶
func (e EstimatedDocumentCount) SetComment(comment any) EstimatedDocumentCount
SetComment sets value for the Comment field.
func (EstimatedDocumentCount) SetMaxTime ¶
func (e EstimatedDocumentCount) SetMaxTime(d time.Duration) EstimatedDocumentCount
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 GetExistsOptionByParams ¶
GetExistsOptionByParams assembles the Exists object from optional parameters.
func (Exists) SetCollation ¶
SetCollation creates a new Collation instance.
func (Exists) SetComment ¶
SetComment creates a new Comment 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 GetFindOptionByParams ¶
GetFindOptionByParams assembles the Find object from optional parameters.
func (Find) SetAllowDiskUse ¶
SetAllowDiskUse creates a new AllowDiskUse instance.
func (Find) SetAllowPartialResults ¶
SetAllowPartialResults creates a new AllowPartialResults instance.
func (Find) SetBatchSize ¶
SetBatchSize creates a new BatchSize instance.
func (Find) SetCollation ¶
SetCollation creates a new Collation instance.
func (Find) SetComment ¶
SetComment creates a new Comment instance.
func (Find) SetCursorType ¶
func (f Find) SetCursorType(c CursorType) Find
SetCursorType creates a new CursorType instance.
func (Find) SetMaxAwaitTime ¶
SetMaxAwaitTime creates a new MaxAwaitTime instance.
func (Find) SetMaxTime ¶
SetMaxTime creates a new MaxTime instance.
func (Find) SetNoCursorTimeout ¶
SetNoCursorTimeout creates a new NoCursorTimeout instance.
func (Find) SetProjection ¶
SetProjection creates a new Projection instance.
func (Find) SetReturnKey ¶
SetReturnKey creates a new ReturnKey instance.
func (Find) SetShowRecordID ¶
SetShowRecordID creates a new ShowRecordID 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 GetFindOneOptionByParams ¶
GetFindOneOptionByParams assembles the FindOne object from optional parameters.
func (FindOne) SetAllowPartialResults ¶
SetAllowPartialResults creates a new AllowPartialResults instance.
func (FindOne) SetCollation ¶
SetCollation creates a new Collation instance.
func (FindOne) SetComment ¶
SetComment creates a new Comment instance.
func (FindOne) SetMaxTime ¶
SetMaxTime creates a new MaxTime instance.
func (FindOne) SetProjection ¶
SetProjection creates a new Projection instance.
func (FindOne) SetReturnKey ¶
SetReturnKey creates a new ReturnKey instance.
func (FindOne) SetShowRecordID ¶
SetShowRecordID creates a new ShowRecordID 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 // 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. 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. ForceRecreateSession bool }
FindOneAndDelete represents options that can be used to configure a FindOneAndDelete operation.
func GetFindOneAndDeleteOptionByParams ¶
func GetFindOneAndDeleteOptionByParams(opts []FindOneAndDelete) FindOneAndDelete
GetFindOneAndDeleteOptionByParams 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(s string) 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) 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 // 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. 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. ForceRecreateSession bool }
FindOneAndReplace represents options that can be used to configure a FindOneAndReplace operation.
func GetFindOneAndReplaceOptionByParams ¶
func GetFindOneAndReplaceOptionByParams(opts []FindOneAndReplace) FindOneAndReplace
GetFindOneAndReplaceOptionByParams 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(s string) 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) 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 ¶
func (f FindOneAndReplace) SetMaxTime(d time.Duration) FindOneAndReplace
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 // 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. 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. ForceRecreateSession bool }
FindOneAndUpdate represents options that can be used to configure a FindOneAndUpdate operation.
func GetFindOneAndUpdateOptionByParams ¶
func GetFindOneAndUpdateOptionByParams(opts []FindOneAndUpdate) FindOneAndUpdate
GetFindOneAndUpdateOptionByParams 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) 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 GetFindOneByIdOptionByParams ¶
func GetFindOneByIdOptionByParams(opts []FindOneById) FindOneById
GetFindOneByIdOptionByParams 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 GetFindPageableOptionByParams ¶
func GetFindPageableOptionByParams(opts []FindPageable) FindPageable
GetFindPageableOptionByParams 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 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 (Index) SetBucketSize ¶
SetBucketSize sets the value for the BucketSize field
func (Index) SetCollation ¶
SetCollation sets the value for the Collation field.
func (Index) SetDefaultLanguage ¶
SetDefaultLanguage sets the value for the DefaultLanguage field.
func (Index) SetExpireAfterSeconds ¶
SetExpireAfterSeconds sets value for the ExpireAfterSeconds field.
func (Index) SetLanguageOverride ¶
SetLanguageOverride sets the value of the LanguageOverride field.
func (Index) SetPartialFilterExpression ¶
SetPartialFilterExpression sets the value for the PartialFilterExpression field.
func (Index) SetSphereVersion ¶
SetSphereVersion sets the value for the SphereVersion field.
func (Index) SetStorageEngine ¶
SetStorageEngine sets the value for the StorageEngine field.
func (Index) SetTextVersion ¶
SetTextVersion sets the value for the TextVersion field.
func (Index) SetVersion ¶
SetVersion sets the value for the Version field.
func (Index) SetWeights ¶
SetWeights sets the value for the Weights field.
func (Index) SetWildcardProjection ¶
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. 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. ForceRecreateSession bool }
InsertMany represents options that can be used to configure a 'InsertMany' operation.
func GetInsertManyOptionByParams ¶
func GetInsertManyOptionByParams(opts []InsertMany) InsertMany
GetInsertManyOptionByParams 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 // 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. 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. ForceRecreateSession bool }
InsertOne represents options that can be used to configure a 'InsertOne' operation.
func GetInsertOneOptionByParams ¶
GetInsertOneOptionByParams assembles the InsertOne object from optional parameters.
func (InsertOne) SetBypassDocumentValidation ¶
SetBypassDocumentValidation sets value for the BypassDocumentValidation field.
func (InsertOne) SetComment ¶
SetComment sets value for the Comment field.
func (InsertOne) SetDisableAutoCloseSession ¶
SetDisableAutoCloseSession creates a new DisableAutoCloseSession instance.
func (InsertOne) SetForceRecreateSession ¶
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 GetListIndexesOptionByParams ¶
func GetListIndexesOptionByParams(opts []ListIndexes) ListIndexes
GetListIndexesOptionByParams 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 // 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. 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. ForceRecreateSession bool }
Replace represents options that can be used to configure a 'ReplaceOne' operation.
func GetReplaceOptionByParams ¶
GetReplaceOptionByParams assembles the Replace object from optional parameters.
func (Replace) SetBypassDocumentValidation ¶
SetBypassDocumentValidation sets value for the BypassDocumentValidation field.
func (Replace) SetCollation ¶
SetCollation sets value for the Collation field.
func (Replace) SetComment ¶
SetComment sets value for the Comment field.
func (Replace) SetDisableAutoCloseSession ¶
SetDisableAutoCloseSession creates a new DisableAutoCloseSession instance.
func (Replace) SetForceRecreateSession ¶
SetForceRecreateSession sets value for the ForceRecreateSession 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 // 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. 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. ForceRecreateSession bool }
Update represents options that can be used to configure a 'UpdateOne' ,'UpdateMany' or 'UpdateOneById' operation.
func GetUpdateOptionByParams ¶
GetUpdateOptionByParams assembles the Update object from optional parameters.
func (Update) SetArrayFilters ¶
func (u Update) SetArrayFilters(a *ArrayFilters) Update
SetArrayFilters sets value for the ArrayFilters field.
func (Update) SetBypassDocumentValidation ¶
SetBypassDocumentValidation sets value for the BypassDocumentValidation field.
func (Update) SetCollation ¶
SetCollation sets value for the Collation field.
func (Update) SetComment ¶
SetComment sets value for the Comment field.
func (Update) SetDisableAutoCloseSession ¶
SetDisableAutoCloseSession creates a new DisableAutoCloseSession instance.
func (Update) SetForceRecreateSession ¶
SetForceRecreateSession sets value for the ForceRecreateSession field.
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 GetWatchOptionByParams ¶
GetWatchOptionByParams assembles the Watch object from optional parameters.
func (Watch) SetBatchSize ¶
SetBatchSize creates a new BatchSize instance.
func (Watch) SetCollation ¶
SetCollation sets value for the Collation field.
func (Watch) SetCollectionName ¶
SetCollectionName creates a new CollectionName instance.
func (Watch) SetComment ¶
SetComment sets value for the Comment field.
func (Watch) SetCustomPipeline ¶
SetCustomPipeline sets value for the CustomPipeline field.
func (Watch) SetDatabaseName ¶
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 ¶
SetMaxAwaitTime sets value for the MaxAwaitTime field.
func (Watch) SetResumeAfter ¶
SetResumeAfter sets value for the ResumeAfter field.
func (Watch) SetShowExpandedEvents ¶
SetShowExpandedEvents sets value for the ShowExpandedEvents field.
func (Watch) SetStartAfter ¶
SetStartAfter sets value for the StartAfter 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 GetWatchHandlerOptionByParams ¶
func GetWatchHandlerOptionByParams(opts []WatchWithHandler) WatchWithHandler
GetWatchHandlerOptionByParams 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.