Documentation
¶
Index ¶
- func AddEachToSet[I expression.AnyExpression](fieldName string, values []I) updateStage
- func AddToSet[I expression.AnyExpression](fieldName string, value I) updateStage
- func BitwiseAnd(fieldName string, value int64) updateStage
- func BitwiseOr(fieldName string, value int64) updateStage
- func BitwiseXor(fieldName string, value int64) updateStage
- func CurrentDate(fieldName string) updateStage
- func CurrentTimestamp(fieldName string) updateStage
- func Inc(fieldName string, number int32) updateStage
- func Max[I expression.AnyExpression](fieldName string, value I) updateStage
- func Min[I expression.AnyExpression](fieldName string, value I) updateStage
- func Mul(fieldName string, number int32) updateStage
- func NewCompositeUpdate(updates []updateStage) compositeUpdate
- func NewPullAllUpdate[T expression.AnyExpression](fieldName string, values []T) pullAllUpdate[T]
- func NewPushUpdate[T expression.AnyExpression](fieldName string, values []T, options PushOptions) pushUpdate[T]
- func NewSimpleBsonKeyValue(fieldName string, value bsonx.IBsonValue) simpleBsonKeyValue
- func NewSimpleUpdate[T expression.AnyExpression](fieldName string, value T, operator string) simpleUpdate[T]
- func NewWithEachUpdate[T expression.AnyExpression](fieldName string, values []T, operator string) withEachUpdate[T]
- func PopFirst(fieldName string) updateStage
- func PopLast(fieldName string) updateStage
- func Pull[I expression.AnyExpression](fieldName string, value I) updateStage
- func PullAll[I expression.AnyExpression](fieldName string, values []I) updateStage
- func PullByFilter(filter filters.Filter) updateStage
- func Push[I expression.AnyExpression](fieldName string, value I) updateStage
- func PushEach[I expression.AnyExpression](fieldName string, values []I, options PushOptions) updateStage
- func Rename(fieldName, newFieldName string) updateStage
- func Set[I expression.AnyExpression](fieldName string, value I) updateStage
- func SetOnInsert[I expression.AnyExpression](fieldName string, value I) updateStage
- func UnSet(fieldName string) updateStage
- type PushOptions
- func (b PushOptions) GetPosition() int32
- func (b PushOptions) GetSlice() int32
- func (b PushOptions) GetSort() int32
- func (b PushOptions) GetSortDocument() bsonx.Bson
- func (b PushOptions) HasPosition() bool
- func (b PushOptions) HasSlice() bool
- func (b PushOptions) HasSort() bool
- func (b PushOptions) Position(position int32) PushOptions
- func (b PushOptions) Slice(slice int32) PushOptions
- func (b PushOptions) Sort(sort int32) PushOptions
- func (b PushOptions) SortDocument(sortDocument bsonx.Bson) PushOptions
- func (b PushOptions) ToString() string
- type Update
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddEachToSet ¶
func AddEachToSet[I expression.AnyExpression](fieldName string, values []I) updateStage
AddEachToSet $addToSet with $each,The $each modifier is available for use with the $addToSet operator and the $push operator. Use with the $addToSet operator to add multiple values to an array <field> if the values do not exist in the <field>. { $addToSet: { <field>: { $each: [ <value1>, <value2> ... ] } } }
func AddToSet ¶
func AddToSet[I expression.AnyExpression](fieldName string, value I) updateStage
AddToSet The $addToSet operator adds a value to an array unless the value is already present, in which case $addToSet does nothing to that array. The $addToSet operator has the form: { $addToSet: { <field1>: <value1>, ... } } To specify a <field> in an embedded document or in an array, use dot notation.
func BitwiseAnd ¶
BitwiseAnd Use a bitwise and in the updateOne() operation to update expdata. db.switches.updateOne(
{ _id: 1 }, { $bit: { expdata: { and: Int32( 10 ) } } }
)
func BitwiseOr ¶
BitwiseOr Use a bitwise or in the updateOne() operation to update expdata.
db.switches.updateOne(
{ _id: 2 }, { $bit: { expdata: { or: Int32( 5 ) } } }
)
func BitwiseXor ¶
BitwiseXor Use a bitwise xor in the updateOne() operation to update expdata.
db.switches.updateOne(
{ _id: 3 }, { $bit: { expdata: { xor: Int32( 5 ) } } }
)
func CurrentDate ¶
func CurrentDate(fieldName string) updateStage
CurrentDate The $currentDate operator sets the value of a field to the current date, either as a Date or a timestamp. The default type is Date. The $currentDate operator has the form: { $currentDate: { <field1>: <typeSpecification1>, ... } } <typeSpecification> can be either: a boolean true to set the field value to the current date as a Date, or a document { $type: "timestamp" } or { $type: "date" } which explicitly specifies the type. The operator is case-sensitive and accepts only the lowercase "timestamp" or the lowercase "date". To specify a <field> in an embedded document or in an array, use dot notation.
func CurrentTimestamp ¶
func CurrentTimestamp(fieldName string) updateStage
CurrentTimestamp The $currentDate operator sets the value of a field to the current date, either as a Date or a timestamp. The default type is Date. The $currentDate operator has the form: { $currentDate: { <field1>: <typeSpecification1>, ... } } <typeSpecification> can be either: a boolean true to set the field value to the current date as a Date, or a document { $type: "timestamp" } or { $type: "date" } which explicitly specifies the type. The operator is case-sensitive and accepts only the lowercase "timestamp" or the lowercase "date". To specify a <field> in an embedded document or in an array, use dot notation.
func Inc ¶
Inc The $inc operator increments a field by a specified value and has the following form: { $inc: { <field1>: <amount1>, <field2>: <amount2>, ... } } To specify a <field> in an embedded document or in an array, use dot notation.
func Max ¶
func Max[I expression.AnyExpression](fieldName string, value I) updateStage
Max The $max operator updates the value of the field to a specified value if the specified value is greater than the current value of the field. The $max operator can compare values of different types, using the BSON comparison order. The $max operator expression has the form: { $max: { <field1>: <value1>, ... } } To specify a <field> in an embedded document or in an array, use dot notation.
func Min ¶
func Min[I expression.AnyExpression](fieldName string, value I) updateStage
Min The $min updates the value of the field to a specified value if the specified value is less than the current value of the field. The $min operator can compare values of different types, using the BSON comparison order. { $min: { <field1>: <value1>, ... } } To specify a <field> in an embedded document or in an array, use dot notation.
func Mul ¶
Mul Multiply the value of a field by a number. To specify a $mul expression, use the following prototype: { $mul: { <field1>: <number1>, ... } } The field to update must contain a numeric value. To specify a <field> in an embedded document or in an array, use dot notation.
func NewCompositeUpdate ¶
func NewCompositeUpdate(updates []updateStage) compositeUpdate
func NewPullAllUpdate ¶
func NewPullAllUpdate[T expression.AnyExpression](fieldName string, values []T) pullAllUpdate[T]
func NewPushUpdate ¶
func NewPushUpdate[T expression.AnyExpression](fieldName string, values []T, options PushOptions) pushUpdate[T]
func NewSimpleBsonKeyValue ¶
func NewSimpleBsonKeyValue(fieldName string, value bsonx.IBsonValue) simpleBsonKeyValue
func NewSimpleUpdate ¶
func NewSimpleUpdate[T expression.AnyExpression](fieldName string, value T, operator string) simpleUpdate[T]
func NewWithEachUpdate ¶
func NewWithEachUpdate[T expression.AnyExpression](fieldName string, values []T, operator string) withEachUpdate[T]
func PopFirst ¶
func PopFirst(fieldName string) updateStage
PopFirst The $pop operator removes the first or last element of an array. Pass $pop a value of -1 to remove the first element of an array and 1 to remove the last element in an array. The $pop operator has the form: { $pop: { <field>: <-1 | 1>, ... } } To specify a <field> in an embedded document or in an array, use dot notation.
func PopLast ¶
func PopLast(fieldName string) updateStage
PopLast The $pop operator removes the first or last element of an array. Pass $pop a value of -1 to remove the first element of an array and 1 to remove the last element in an array. The $pop operator has the form: { $pop: { <field>: <-1 | 1>, ... } } To specify a <field> in an embedded document or in an array, use dot notation.
func Pull ¶
func Pull[I expression.AnyExpression](fieldName string, value I) updateStage
Pull The $pull operator removes from an existing array all instances of a value or values that match a specified condition. The $pull operator has the form: { $pull: { <field1>: <value|condition>, <field2>: <value|condition>, ... } } To specify a <field> in an embedded document or in an array, use dot notation.
func PullAll ¶
func PullAll[I expression.AnyExpression](fieldName string, values []I) updateStage
PullAll The $pullAll operator removes all instances of the specified values from an existing array. Unlike the $pull operator that removes elements by specifying a query, $pullAll removes elements that match the listed values. The $pullAll operator has the form: { $pullAll: { <field1>: [ <value1>, <value2> ... ], ... } } To specify a <field> in an embedded document or in an array, use dot notation.
func PullByFilter ¶
PullByFilter The $pull operator removes from an existing array all instances of a value or values that match a specified condition. The $pull operator has the form: { $pull: { <field1>: <value|condition>, <field2>: <value|condition>, ... } } To specify a <field> in an embedded document or in an array, use dot notation.
func Push ¶
func Push[I expression.AnyExpression](fieldName string, value I) updateStage
Push The $push operator appends a specified value to an array. The $push operator has the form: { $push: { <field1>: <value1>, ... } } To specify a <field> in an embedded document or in an array, use dot notation.
func PushEach ¶
func PushEach[I expression.AnyExpression](fieldName string, values []I, options PushOptions) updateStage
PushEach Use with the $push operator to append multiple values to an array <field>. { $push: { <field>: { $each: [ <value1>, <value2> ... ] } } } The $push operator can use $each modifier with other modifiers. For a list of modifiers available for $push, see Modifiers.
func Rename ¶
func Rename(fieldName, newFieldName string) updateStage
Rename The $rename operator updates the name of a field and has the following form: {$rename: { <field1>: <newName1>, <field2>: <newName2>, ... } } The new field name must differ from the existing field name. To specify a <field> in an embedded document, use dot notation. Consider the following example: db.students.updateOne(
{ _id: 1 }, { $rename: { 'nickname': 'alias', 'cell': 'mobile' } }
) This operation renames the field nickname to alias, and the field cell to mobile.
func Set ¶
func Set[I expression.AnyExpression](fieldName string, value I) updateStage
Set The $set operator replaces the value of a field with the specified value. The $set operator expression has the following form: { $set: { <field1>: <value1>, ... } } To specify a <field> in an embedded document or in an array, use dot notation.
func SetOnInsert ¶
func SetOnInsert[I expression.AnyExpression](fieldName string, value I) updateStage
SetOnInsert If an update operation with upsert: true results in an insert of a document, then $setOnInsert assigns the specified values to the fields in the document. If the update operation does not result in an insert, $setOnInsert does nothing. db.collection.updateOne(
<query>, { $setOnInsert: { <field1>: <value1>, ... } }, { upsert: true }
)
func UnSet ¶
func UnSet(fieldName string) updateStage
UnSet The $unset operator deletes a particular field. Consider the following syntax: { $unset: { <field1>: "", ... } } The specified value in the $unset expression (i.e. "") does not impact the operation. To specify a <field> in an embedded document or in an array, use dot notation.
Types ¶
type PushOptions ¶
type PushOptions struct {
// contains filtered or unexported fields
}
func NewPushOptions ¶
func NewPushOptions() PushOptions
func (PushOptions) GetPosition ¶
func (b PushOptions) GetPosition() int32
func (PushOptions) GetSlice ¶
func (b PushOptions) GetSlice() int32
func (PushOptions) GetSort ¶
func (b PushOptions) GetSort() int32
func (PushOptions) GetSortDocument ¶
func (b PushOptions) GetSortDocument() bsonx.Bson
func (PushOptions) HasPosition ¶
func (b PushOptions) HasPosition() bool
func (PushOptions) HasSlice ¶
func (b PushOptions) HasSlice() bool
func (PushOptions) HasSort ¶
func (b PushOptions) HasSort() bool
func (PushOptions) Position ¶
func (b PushOptions) Position(position int32) PushOptions
func (PushOptions) Slice ¶
func (b PushOptions) Slice(slice int32) PushOptions
func (PushOptions) Sort ¶
func (b PushOptions) Sort(sort int32) PushOptions
func (PushOptions) SortDocument ¶
func (b PushOptions) SortDocument(sortDocument bsonx.Bson) PushOptions
func (PushOptions) ToString ¶
func (b PushOptions) ToString() string