creator

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Creator

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

func NewCreator

func NewCreator[T any](collection *mongo.Collection) *Creator[T]

func (*Creator[T]) InsertMany

func (c *Creator[T]) InsertMany(ctx context.Context, docs []*T, opts ...*options.InsertManyOptions) (*mongo.InsertManyResult, error)

func (*Creator[T]) InsertOne

func (c *Creator[T]) InsertOne(ctx context.Context, doc *T, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)

func (*Creator[T]) ModelHook added in v1.4.0

func (c *Creator[T]) ModelHook(modelHook any) *Creator[T]

func (*Creator[T]) RegisterAfterHooks added in v0.12.0

func (c *Creator[T]) RegisterAfterHooks(hooks ...hookFn[T]) *Creator[T]

func (*Creator[T]) RegisterBeforeHooks added in v0.12.0

func (c *Creator[T]) RegisterBeforeHooks(hooks ...hookFn[T]) *Creator[T]

RegisterBeforeHooks is used to set the after hooks of the insert operation If you register the hook for InsertOne, the opContext.Docs will be nil If you register the hook for InsertMany, the opContext.Doc will be nil

type ICreator added in v1.7.0

type ICreator[T any] interface {
	InsertOne(ctx context.Context, docs *T, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)
	InsertMany(ctx context.Context, docs []*T, opts ...*options.InsertManyOptions) (*mongo.InsertManyResult, error)
}

type OpContext added in v0.13.0

type OpContext[T any] struct {
	Col          *mongo.Collection `opt:"-"`
	Doc          *T
	Docs         []*T
	MongoOptions any
	ModelHook    any
}

func NewOpContext added in v0.13.0

func NewOpContext[T any](col *mongo.Collection, opts ...OpContextOption[T]) *OpContext[T]

type OpContextOption added in v0.13.0

type OpContextOption[T any] func(*OpContext[T])

func WithDoc added in v0.12.0

func WithDoc[T any](doc *T) OpContextOption[T]

func WithDocs added in v0.12.0

func WithDocs[T any](docs []*T) OpContextOption[T]

func WithModelHook added in v1.4.0

func WithModelHook[T any](modelHook any) OpContextOption[T]

func WithMongoOptions added in v1.3.0

func WithMongoOptions[T any](mongoOptions any) OpContextOption[T]

Jump to

Keyboard shortcuts

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