Documentation ¶
Index ¶
- type AfterOpContext
- type AfterOpContextOption
- type Finder
- func (f *Finder[T]) Count(ctx context.Context, opts ...*options.CountOptions) (int64, error)
- func (f *Finder[T]) Distinct(ctx context.Context, fieldName string, opts ...*options.DistinctOptions) ([]any, error)
- func (f *Finder[T]) DistinctWithParse(ctx context.Context, fieldName string, result any, ...) error
- func (f *Finder[T]) Filter(filter any) *Finder[T]
- func (f *Finder[T]) Find(ctx context.Context, opts ...*options.FindOptions) ([]*T, error)
- func (f *Finder[T]) FindOne(ctx context.Context, opts ...*options.FindOneOptions) (*T, error)
- func (f *Finder[T]) FindOneAndUpdate(ctx context.Context, opts ...*options.FindOneAndUpdateOptions) (*T, error)
- func (f *Finder[T]) ModelHook(modelHook any) *Finder[T]
- func (f *Finder[T]) RegisterAfterHooks(hooks ...afterHookFn[T]) *Finder[T]
- func (f *Finder[T]) RegisterBeforeHooks(hooks ...beforeHookFn) *Finder[T]
- func (f *Finder[T]) Updates(update any) *Finder[T]
- type IFinder
- type IllegalUser
- type OpContext
- type OpContextOption
- type TestTempUser
- type TestUser
- type UpdatedUser
- type UserName
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AfterOpContext ¶ added in v0.12.0
func NewAfterOpContext ¶ added in v0.12.0
func NewAfterOpContext[T any](opContext *OpContext, opts ...AfterOpContextOption[T]) *AfterOpContext[T]
type AfterOpContextOption ¶ added in v0.12.0
type AfterOpContextOption[T any] func(*AfterOpContext[T])
func WithDoc ¶ added in v0.12.0
func WithDoc[T any](doc *T) AfterOpContextOption[T]
func WithDocs ¶ added in v0.12.0
func WithDocs[T any](docs []*T) AfterOpContextOption[T]
type Finder ¶
type Finder[T any] struct { // contains filtered or unexported fields }
func (*Finder[T]) DistinctWithParse ¶ added in v0.11.0
func (f *Finder[T]) DistinctWithParse(ctx context.Context, fieldName string, result any, opts ...*options.DistinctOptions) error
DistinctWithParse is used to parse the result of Distinct result must be a pointer
func (*Finder[T]) FindOneAndUpdate ¶ added in v1.2.0
func (*Finder[T]) RegisterAfterHooks ¶ added in v0.12.0
RegisterAfterHooks is used to set the after hooks of the query If you register the hook for FindOne, the opContext.Docs will be nil If you register the hook for Find, the opContext.Doc will be nil
func (*Finder[T]) RegisterBeforeHooks ¶ added in v0.12.0
type IFinder ¶ added in v1.7.0
type IFinder[T any] interface { FindOne(ctx context.Context, opts ...*options.FindOneOptions) (*T, error) Find(ctx context.Context, opts ...*options.FindOptions) ([]*T, error) Count(ctx context.Context, opts ...*options.CountOptions) (int64, error) Distinct(ctx context.Context, fieldName string, opts ...*options.DistinctOptions) ([]any, error) DistinctWithParse(ctx context.Context, fieldName string, result any, opts ...*options.DistinctOptions) error FindOneAndUpdate(ctx context.Context, opts ...*options.FindOneAndUpdateOptions) (*T, error) }
type IllegalUser ¶ added in v1.0.0
type OpContext ¶ added in v0.12.0
type OpContext struct { Col *mongo.Collection `opt:"-"` Filter any `opt:"-"` Updates any MongoOptions any ModelHook any }
func NewOpContext ¶ added in v0.12.0
func NewOpContext(col *mongo.Collection, filter any, opts ...OpContextOption) *OpContext
type OpContextOption ¶ added in v0.12.0
type OpContextOption func(*OpContext)
func WithModelHook ¶ added in v1.4.0
func WithModelHook(modelHook any) OpContextOption
func WithMongoOptions ¶ added in v1.3.0
func WithMongoOptions(mongoOptions any) OpContextOption
func WithUpdates ¶ added in v1.2.0
func WithUpdates(updates any) OpContextOption
type TestTempUser ¶ added in v1.0.0
type TestUser ¶ added in v1.0.0
type TestUser struct { ID primitive.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 ¶ added in v1.0.0
func (tu *TestUser) DefaultCreatedAt()
func (*TestUser) DefaultUpdatedAt ¶ added in v1.0.0
func (tu *TestUser) DefaultUpdatedAt()
type UpdatedUser ¶ added in v1.0.0
Click to show internal directories.
Click to hide internal directories.