update

package
v0.0.28 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArrayFilters

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

func NewArrayFilters

func NewArrayFilters(filters ...*filters.Filter) *ArrayFilters

func (*ArrayFilters) Raw

func (af *ArrayFilters) Raw() options.ArrayFilters

func (*ArrayFilters) Registry

func (af *ArrayFilters) Registry(r *bsoncodec.Registry) *ArrayFilters

type PopType

type PopType int8
const (
	PopFirst PopType = -1
	PopLast  PopType = 1
)

type TypedUpdateManyModel

type TypedUpdateManyModel struct {
	TypedWriteModel
	// contains filtered or unexported fields
}

func NewUpdateMany

func NewUpdateMany() *TypedUpdateManyModel

NewUpdateMany creates a new UpdateManyModel.

func (*TypedUpdateManyModel) SetArrayFilters

func (umm *TypedUpdateManyModel) SetArrayFilters(filters options.ArrayFilters) *TypedUpdateManyModel

SetArrayFilters specifies a set of filters to determine which elements should be modified when updating an array field.

func (*TypedUpdateManyModel) SetCollation

func (umm *TypedUpdateManyModel) SetCollation(collation *options.Collation) *TypedUpdateManyModel

SetCollation specifies a collation to use for string comparisons. The default is nil, meaning no collation will be used.

func (*TypedUpdateManyModel) SetFilter

func (umm *TypedUpdateManyModel) SetFilter(filter *filters.Filter) *TypedUpdateManyModel

SetFilter specifies a filter to use to select documents to update. The filter must be a document containing query operators. It cannot be nil.

func (*TypedUpdateManyModel) SetHint

func (umm *TypedUpdateManyModel) SetHint(index string) *TypedUpdateManyModel

SetHint specifies 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.

func (*TypedUpdateManyModel) SetUpdate

func (umm *TypedUpdateManyModel) SetUpdate(update Update) *TypedUpdateManyModel

SetUpdate specifies the modifications to be made to the selected documents. The value must be a document containing update operators (https://www.mongodb.com/docs/manual/reference/operator/update/). It cannot be nil or empty.

func (*TypedUpdateManyModel) SetUpsert

func (umm *TypedUpdateManyModel) SetUpsert(upsert bool) *TypedUpdateManyModel

SetUpsert specifies whether or not a new document should be inserted if no document matching the filter is found. If an upsert is performed, the _id of the upserted document can be retrieved from the UpsertedIDs field of the BulkWriteResult.

func (*TypedUpdateManyModel) WriteModel

func (umm *TypedUpdateManyModel) WriteModel() mongo.WriteModel

type TypedUpdateOneModel

type TypedUpdateOneModel struct {
	TypedWriteModel
	// contains filtered or unexported fields
}

func NewUpdateOne

func NewUpdateOne() *TypedUpdateOneModel

NewUpdateOne creates a new UpdateOneModel.

func (*TypedUpdateOneModel) ArrayFilters

func (uom *TypedUpdateOneModel) ArrayFilters(filters options.ArrayFilters) *TypedUpdateOneModel

ArrayFilters specifies a set of filters to determine which elements should be modified when updating an array field.

func (*TypedUpdateOneModel) Collation

func (uom *TypedUpdateOneModel) Collation(collation *options.Collation) *TypedUpdateOneModel

Collation specifies a collation to use for string comparisons. The default is nil, meaning no collation will be used.

func (*TypedUpdateOneModel) Filter

func (uom *TypedUpdateOneModel) Filter(filter *filters.Filter) *TypedUpdateOneModel

Filter specifies a filter to use to select the document to update. The filter must be a document containing query operators. It cannot be nil. If the filter matches multiple documents, one will be selected from the matching documents.

func (*TypedUpdateOneModel) Hint

Hint specifies 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.

func (*TypedUpdateOneModel) Update

func (uom *TypedUpdateOneModel) Update(update *Update) *TypedUpdateOneModel

Update specifies the modifications to be made to the selected document. The value must be a document containing update operators (https://docs.mongodb.com/manual/reference/operator/update/). It cannot be nil or empty.

func (*TypedUpdateOneModel) Upsert

func (uom *TypedUpdateOneModel) Upsert(upsert bool) *TypedUpdateOneModel

Upsert specifies whether or not a new document should be inserted if no document matching the filter is found. If an upsert is performed, the _id of the upserted document can be retrieved from the UpsertedIDs field of the BulkWriteResult.

func (*TypedUpdateOneModel) WriteModel

func (uom *TypedUpdateOneModel) WriteModel() mongo.WriteModel

type TypedWriteModel

type TypedWriteModel interface {
	WriteModel() mongo.WriteModel
}

type Update

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

func AddEachToSet

func AddEachToSet[T any](field string, value []T) *Update

func AddToSet

func AddToSet(field string, value any) *Update

func CurrentDate

func CurrentDate(fields ...string) *Update

func CurrentTimestamp

func CurrentTimestamp(fields ...string) *Update

func Dec

func Dec(field string, delta int) *Update

func Inc

func Inc(field string, delta int) *Update

func InsertAll

func InsertAll(field string, value []any, index int) *Update

func MaxFloat32

func MaxFloat32(field string, cur float32) *Update

func MaxFloat64

func MaxFloat64(field string, cur float64) *Update

func MaxInt

func MaxInt(field string, cur int) *Update

func MaxInt32

func MaxInt32(field string, cur int32) *Update

func MaxInt64

func MaxInt64(field string, cur int64) *Update

func MaxTime

func MaxTime(field string, time time.Time) *Update

func MinFloat32

func MinFloat32(field string, cur float32) *Update

func MinFloat64

func MinFloat64(field string, cur float64) *Update

func MinInt

func MinInt(field string, cur int) *Update

func MinInt32

func MinInt32(field string, cur int32) *Update

func MinInt64

func MinInt64(field string, cur int64) *Update

func MinTime

func MinTime(field string, time time.Time) *Update

func New

func New() *Update

func Pop

func Pop(field string, pType PopType) *Update

func Pull

func Pull(field string, value any) *Update

func PullAll

func PullAll(field string, value []any) *Update

func PullConditioned

func PullConditioned(condition *filters.Filter) *Update

func Push

func Push(field string, value any) *Update

func PushEach

func PushEach(field string, value []any) *Update

func PushLimited

func PushLimited(field string, value []string, limit int) *Update

func PushSorted

func PushSorted(field string, value []string, sort *sorts.Options) *Update

func Rename

func Rename(field, newname string) *Update

func Set

func Set(field string, value any) *Update

func SetAll

func SetAll(pairs bson.M) *Update

func SetOnInsert

func SetOnInsert(field string, value any) *Update

func SetOnInsertAll

func SetOnInsertAll(pairs bson.M) *Update

func Unset

func Unset(fields ...string) *Update

func (*Update) AddEachToSet

func (u *Update) AddEachToSet(field string, value []any) *Update

func (*Update) AddToSet

func (u *Update) AddToSet(field string, value any) *Update

func (*Update) BitAnd

func (u *Update) BitAnd(field string, val int) *Update

func (*Update) BitOr

func (u *Update) BitOr(field string, val int) *Update

func (*Update) BitXor

func (u *Update) BitXor(field string, val int) *Update

func (*Update) CurrentDate

func (u *Update) CurrentDate(fields ...string) *Update

func (*Update) CurrentTimestamp

func (u *Update) CurrentTimestamp(fields ...string) *Update

func (*Update) Dec

func (u *Update) Dec(field string, delta int) *Update

func (*Update) Document

func (u *Update) Document() bson.M

func (*Update) Inc

func (u *Update) Inc(field string, delta int) *Update

func (*Update) InsertAll

func (u *Update) InsertAll(field string, value []any, index int) *Update

func (*Update) MarshalBSON added in v0.0.26

func (u *Update) MarshalBSON() ([]byte, error)

func (*Update) MaxFloat32

func (u *Update) MaxFloat32(field string, cur float32) *Update

func (*Update) MaxFloat64

func (u *Update) MaxFloat64(field string, cur float64) *Update

func (*Update) MaxInt

func (u *Update) MaxInt(field string, cur int) *Update

func (*Update) MaxInt32

func (u *Update) MaxInt32(field string, cur int32) *Update

func (*Update) MaxInt64

func (u *Update) MaxInt64(field string, cur int64) *Update

func (*Update) MaxTime

func (u *Update) MaxTime(field string, time time.Time) *Update

func (*Update) MinFloat32

func (u *Update) MinFloat32(field string, cur float32) *Update

func (*Update) MinFloat64

func (u *Update) MinFloat64(field string, cur float64) *Update

func (*Update) MinInt

func (u *Update) MinInt(field string, cur int) *Update

func (*Update) MinInt32

func (u *Update) MinInt32(field string, cur int32) *Update

func (*Update) MinInt64

func (u *Update) MinInt64(field string, cur int64) *Update

func (*Update) MinTime

func (u *Update) MinTime(field string, time time.Time) *Update

func (*Update) Pop

func (u *Update) Pop(field string, pType PopType) *Update

func (*Update) Pull

func (u *Update) Pull(field string, value any) *Update

func (*Update) PullAll

func (u *Update) PullAll(field string, value []any) *Update

func (*Update) PullConditioned

func (u *Update) PullConditioned(condition *filters.Filter) *Update

func (*Update) Push

func (u *Update) Push(field string, value any) *Update

func (*Update) PushEach

func (u *Update) PushEach(field string, value []any) *Update

func (*Update) PushLimited

func (u *Update) PushLimited(field string, value []string, limit int) *Update

func (*Update) PushSorted

func (u *Update) PushSorted(field string, value []string, sort *sorts.Options) *Update

func (*Update) Rename

func (u *Update) Rename(field, newname string) *Update

func (*Update) Set

func (u *Update) Set(field string, value any) *Update

func (*Update) SetAll

func (u *Update) SetAll(pairs bson.M) *Update

func (*Update) SetOnInsert

func (u *Update) SetOnInsert(field string, value any) *Update

func (*Update) SetOnInsertAll

func (u *Update) SetOnInsertAll(pairs bson.M) *Update

func (*Update) Unset

func (u *Update) Unset(fields ...string) *Update

Jump to

Keyboard shortcuts

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