updater

package
v2.0.0-beta1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AfterOpContext

type AfterOpContext struct {
	Col          *mongo.Collection `opt:"-"`
	*CondContext `opt:"-"`
}

func NewAfterOpContext

func NewAfterOpContext(col *mongo.Collection, condContext *CondContext, opts ...AfterOpContextOption) *AfterOpContext

type AfterOpContextOption

type AfterOpContextOption func(*AfterOpContext)

type BeforeOpContext

type BeforeOpContext struct {
	Col          *mongo.Collection `opt:"-"`
	*CondContext `opt:"-"`
}

func NewBeforeOpContext

func NewBeforeOpContext(col *mongo.Collection, condContext *CondContext, opts ...BeforeOpContextOption) *BeforeOpContext

type BeforeOpContextOption

type BeforeOpContextOption func(*BeforeOpContext)

type CondContext

type CondContext struct {
	Filter       any `opt:"-"`
	Updates      any
	Replacement  any
	MongoOptions any
	ModelHook    any
}

func NewCondContext

func NewCondContext(filter any, opts ...CondContextOption) *CondContext

type CondContextOption

type CondContextOption func(*CondContext)

func WithModelHook

func WithModelHook(modelHook any) CondContextOption

func WithMongoOptions

func WithMongoOptions(mongoOptions any) CondContextOption

func WithReplacement

func WithReplacement(replacement any) CondContextOption

func WithUpdates

func WithUpdates(updates any) CondContextOption

type TestUser

type TestUser struct {
	ID           bson.ObjectID `bson:"_id,omitempty"`
	Name         string        `bson:"name"`
	Age          int64
	UnknownField string    `bson:"-"`
	CreatedAt    time.Time `bson:"created_at"`
	UpdatedAt    time.Time `bson:"updated_at"`
}

func (*TestUser) DefaultCreatedAt

func (m *TestUser) DefaultCreatedAt() time.Time

func (*TestUser) DefaultId

func (m *TestUser) DefaultId() bson.ObjectID

func (*TestUser) DefaultUpdatedAt

func (m *TestUser) DefaultUpdatedAt() time.Time

type TestUser2

type TestUser2 struct {
	ID           string `bson:"_id,omitempty"`
	Name         string `bson:"name"`
	Age          int64
	UnknownField string    `bson:"-"`
	CreatedAt    time.Time `bson:"createdAt"`
	UpdatedAt    time.Time `bson:"updatedAt"`
}

func (*TestUser2) CustomCreatedAt

func (m *TestUser2) CustomCreatedAt() (string, any)

func (*TestUser2) CustomID

func (m *TestUser2) CustomID() (string, any)

func (*TestUser2) CustomUpdatedAt

func (m *TestUser2) CustomUpdatedAt() (string, any)

type Updater

type Updater[T any] struct {
	// contains filtered or unexported fields
}

func NewUpdater

func NewUpdater[T any](collection *mongo.Collection) *Updater[T]

func (*Updater[T]) Filter

func (u *Updater[T]) Filter(filter any) *Updater[T]

Filter is used to set the filter of the query

func (*Updater[T]) ModelHook

func (u *Updater[T]) ModelHook(modelHook any) *Updater[T]

func (*Updater[T]) RegisterAfterHooks

func (u *Updater[T]) RegisterAfterHooks(hooks ...afterHookFn) *Updater[T]

func (*Updater[T]) RegisterBeforeHooks

func (u *Updater[T]) RegisterBeforeHooks(hooks ...beforeHookFn) *Updater[T]

func (*Updater[T]) Replacement

func (u *Updater[T]) Replacement(replacement any) *Updater[T]

func (*Updater[T]) UpdateMany

func (u *Updater[T]) UpdateMany(ctx context.Context, opts ...options.Lister[options.UpdateOptions]) (*mongo.UpdateResult, error)

func (*Updater[T]) UpdateOne

func (u *Updater[T]) UpdateOne(ctx context.Context, opts ...options.Lister[options.UpdateOptions]) (*mongo.UpdateResult, error)

func (*Updater[T]) Updates

func (u *Updater[T]) Updates(updates any) *Updater[T]

Updates is used to set the updates of the update

func (*Updater[T]) Upsert

type User

type User struct {
	Id           string `bson:"_id"`
	Name         string `bson:"name"`
	Age          int64
	UnknownField string `bson:"-"`
}

Jump to

Keyboard shortcuts

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