finder

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AfterOpContext added in v0.12.0

type AfterOpContext[T any] struct {
	*OpContext `opt:"-"`
	Doc        *T
	Docs       []*T
}

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 NewFinder

func NewFinder[T any](collection *mongo.Collection) *Finder[T]

func (*Finder[T]) Count added in v0.0.4

func (f *Finder[T]) Count(ctx context.Context, opts ...*options.CountOptions) (int64, error)

func (*Finder[T]) Distinct added in v0.11.0

func (f *Finder[T]) Distinct(ctx context.Context, fieldName string, opts ...*options.DistinctOptions) ([]any, error)

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]) Filter

func (f *Finder[T]) Filter(filter any) *Finder[T]

Filter is used to set the filter of the query

func (*Finder[T]) Find added in v0.0.7

func (f *Finder[T]) Find(ctx context.Context, opts ...*options.FindOptions) ([]*T, error)

func (*Finder[T]) FindOne

func (f *Finder[T]) FindOne(ctx context.Context, opts ...*options.FindOneOptions) (*T, error)

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

func (f *Finder[T]) RegisterAfterHooks(hooks ...afterHookFn[T]) *Finder[T]

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

func (f *Finder[T]) RegisterBeforeHooks(hooks ...beforeHookFn) *Finder[T]

type IllegalUser added in v1.0.0

type IllegalUser struct {
	ID   primitive.ObjectID `bson:"_id,omitempty"`
	Name string             `bson:"name"`
	Age  string
}

type OpContext added in v0.12.0

type OpContext struct {
	Col    *mongo.Collection `opt:"-"`
	Filter any               `opt:"-"`
}

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)

type TestTempUser added in v1.0.0

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

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

type UpdatedUser struct {
	Name string `bson:"name"`
	Age  int64
}

type UserName added in v1.0.0

type UserName struct {
	Name string `bson:"name"`
}

Jump to

Keyboard shortcuts

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