update

package
v1.4.5 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder represents a fluent update builder for MongoDB update operations

func AddToSet

func AddToSet(field string, value any) *Builder

AddToSet adds a value to an array only if it doesn't already exist

func Inc

func Inc(field string, value any) *Builder

Inc increments the value of a field by a specified amount

func Mul

func Mul(field string, value any) *Builder

Mul multiplies the value of a field by a specified amount

func New

func New() *Builder

New creates a new update builder

func PopFirst

func PopFirst(field string) *Builder

PopFirst removes the first element from an array

func PopLast

func PopLast(field string) *Builder

PopLast removes the last element from an array

func Pull

func Pull(field string, filterBuilder *filter.Builder) *Builder

Pull removes all instances of a value from an array that match a specified condition

func Push

func Push(field string, value any) *Builder

Push appends a value to an array

func PushEach

func PushEach(field string, values ...any) *Builder

PushEach appends multiple values to an array

func Rename

func Rename(from, to string) *Builder

Rename renames a field

func Set

func Set(field string, value any) *Builder

Set sets the value of a field

func SetMap added in v1.3.0

func SetMap(fields map[string]any) *Builder

SetMap sets multiple fields from a map

func SetOnInsert

func SetOnInsert(field string, value any) *Builder

SetOnInsert sets the value of a field only when an upsert inserts a document

func SetOnInsertMap added in v1.3.0

func SetOnInsertMap(fields map[string]any) *Builder

SetOnInsertMap sets multiple fields from a map only when an upsert inserts a document

func SetOnInsertStruct added in v1.3.0

func SetOnInsertStruct(document any) *Builder

SetOnInsertStruct sets all fields from a struct only when an upsert inserts a document

func SetStruct added in v1.3.0

func SetStruct(document any) *Builder

SetStruct sets all fields from a struct

func Unset

func Unset(fields ...string) *Builder

Unset removes the specified fields

func (*Builder) AddToSet

func (b *Builder) AddToSet(field string, value any) *Builder

AddToSet adds a value to an array only if it doesn't already exist (method version)

func (*Builder) And

func (b *Builder) And(updates ...*Builder) *Builder

And combines multiple update operations

func (*Builder) Build

func (b *Builder) Build() bson.M

Build returns the underlying BSON update document

func (*Builder) Inc

func (b *Builder) Inc(field string, value any) *Builder

Inc increments the value of a field by a specified amount (method version)

func (*Builder) Mul

func (b *Builder) Mul(field string, value any) *Builder

Mul multiplies the value of a field by a specified amount (method version)

func (*Builder) PopFirst

func (b *Builder) PopFirst(field string) *Builder

PopFirst removes the first element from an array (method version)

func (*Builder) PopLast

func (b *Builder) PopLast(field string) *Builder

PopLast removes the last element from an array (method version)

func (*Builder) Pull

func (b *Builder) Pull(field string, filterBuilder *filter.Builder) *Builder

Pull removes all instances of a value from an array that match a specified condition (method version)

func (*Builder) Push

func (b *Builder) Push(field string, value any) *Builder

Push appends a value to an array (method version)

func (*Builder) PushEach

func (b *Builder) PushEach(field string, values ...any) *Builder

PushEach appends multiple values to an array (method version)

func (*Builder) Rename

func (b *Builder) Rename(from, to string) *Builder

Rename renames a field (method version)

func (*Builder) Set

func (b *Builder) Set(field string, value any) *Builder

Set sets the value of a field (method version)

func (*Builder) SetMap added in v1.3.0

func (b *Builder) SetMap(fields map[string]any) *Builder

SetMap sets multiple fields from a map (method version)

func (*Builder) SetOnInsert

func (b *Builder) SetOnInsert(field string, value any) *Builder

SetOnInsert sets the value of a field only when an upsert inserts a document (method version)

func (*Builder) SetOnInsertMap added in v1.3.0

func (b *Builder) SetOnInsertMap(fields map[string]any) *Builder

SetOnInsertMap sets multiple fields from a map only when an upsert inserts a document (method version)

func (*Builder) SetOnInsertStruct added in v1.3.0

func (b *Builder) SetOnInsertStruct(document any) *Builder

SetOnInsertStruct sets all fields from a struct only when an upsert inserts a document (method version)

func (*Builder) SetStruct added in v1.3.0

func (b *Builder) SetStruct(document any) *Builder

SetStruct sets all fields from a struct (method version)

func (*Builder) ToBSONM

func (b *Builder) ToBSONM() bson.M

ToBSONM converts the update to a bson.M for compatibility

func (*Builder) Unset

func (b *Builder) Unset(fields ...string) *Builder

Unset removes the specified fields (method version)

Jump to

Keyboard shortcuts

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