Documentation
¶
Index ¶
- type Creator
- func (c *Creator[T]) InsertMany(ctx context.Context, docs []*T, ...) (*mongo.InsertManyResult, error)
- func (c *Creator[T]) InsertOne(ctx context.Context, doc *T, opts ...options.Lister[options.InsertOneOptions]) (*mongo.InsertOneResult, error)
- func (c *Creator[T]) ModelHook(modelHook any) *Creator[T]
- func (c *Creator[T]) RegisterAfterHooks(hooks ...hookFn[T]) *Creator[T]
- func (c *Creator[T]) RegisterBeforeHooks(hooks ...hookFn[T]) *Creator[T]
- type ICreator
- type OpContext
- type OpContextOption
- func WithDoc[T any](doc *T) OpContextOption[T]
- func WithDocs[T any](docs []*T) OpContextOption[T]
- func WithFields[T any](fields []*field.Filed) OpContextOption[T]
- func WithModelHook[T any](modelHook any) OpContextOption[T]
- func WithMongoOptions[T any](mongoOptions any) OpContextOption[T]
- func WithReflectValue[T any](reflectValue reflect.Value) OpContextOption[T]
- func WithResult[T any](result any) OpContextOption[T]
- func WithStartTime[T any](startTime time.Time) OpContextOption[T]
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 (*Creator[T]) InsertMany ¶
func (c *Creator[T]) InsertMany(ctx context.Context, docs []*T, opts ...options.Lister[options.InsertManyOptions]) (*mongo.InsertManyResult, error)
func (*Creator[T]) InsertOne ¶
func (c *Creator[T]) InsertOne(ctx context.Context, doc *T, opts ...options.Lister[options.InsertOneOptions]) (*mongo.InsertOneResult, error)
func (*Creator[T]) RegisterAfterHooks ¶
func (*Creator[T]) RegisterBeforeHooks ¶
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 ¶
type ICreator[T any] interface { InsertOne(ctx context.Context, docs *T, opts ...options.Lister[options.InsertOneOptions]) (*mongo.InsertOneResult, error) InsertMany(ctx context.Context, docs []*T, opts ...options.Lister[options.InsertManyOptions]) (*mongo.InsertManyResult, error) }
type OpContext ¶
type OpContext[T any] struct { Col *mongo.Collection `opt:"-"` Fields []*field.Filed Doc *T Docs []*T MongoOptions any ModelHook any ReflectValue reflect.Value StartTime time.Time Result any }
func NewOpContext ¶
func NewOpContext[T any](col *mongo.Collection, opts ...OpContextOption[T]) *OpContext[T]
type OpContextOption ¶
func WithDoc ¶
func WithDoc[T any](doc *T) OpContextOption[T]
func WithDocs ¶
func WithDocs[T any](docs []*T) OpContextOption[T]
func WithFields ¶ added in v2.2.0
func WithFields[T any](fields []*field.Filed) OpContextOption[T]
func WithModelHook ¶
func WithModelHook[T any](modelHook any) OpContextOption[T]
func WithMongoOptions ¶
func WithMongoOptions[T any](mongoOptions any) OpContextOption[T]
func WithReflectValue ¶ added in v2.2.0
func WithReflectValue[T any](reflectValue reflect.Value) OpContextOption[T]
func WithResult ¶ added in v2.2.0
func WithResult[T any](result any) OpContextOption[T]
func WithStartTime ¶ added in v2.2.0
func WithStartTime[T any](startTime time.Time) OpContextOption[T]
Click to show internal directories.
Click to hide internal directories.