mgo

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: May 12, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

type DeleteExecutor added in v0.2.2

type DeleteExecutor[T Entity] struct {
	// contains filtered or unexported fields
}

func NewDeleteExecutor added in v0.2.2

func NewDeleteExecutor[T Entity](col *mongo.Collection) *DeleteExecutor[T]

func (*DeleteExecutor[T]) ByID added in v0.2.2

func (d *DeleteExecutor[T]) ByID(ctx context.Context, a primitive.ObjectID) (int64, error)

type Entity added in v0.2.2

type Entity interface {
	GetObjectID() (primitive.ObjectID, string)
	SetObjectID(p primitive.ObjectID)
	IsNil() bool
}

type FinderExecutor added in v0.2.2

type FinderExecutor[T Entity] struct {
	// contains filtered or unexported fields
}

func NewFinderExecutor added in v0.2.2

func NewFinderExecutor[T Entity](col *mongo.Collection) *FinderExecutor[T]

func (*FinderExecutor[T]) All added in v0.2.2

func (f *FinderExecutor[T]) All(ctx context.Context) ([]T, error)

func (*FinderExecutor[T]) Filter added in v0.2.2

func (f *FinderExecutor[T]) Filter(filter ...primitive.E) *FinderExecutor[T]

func (*FinderExecutor[T]) Limit added in v0.2.2

func (f *FinderExecutor[T]) Limit(l int64) *FinderExecutor[T]

func (*FinderExecutor[T]) One added in v0.2.2

func (f *FinderExecutor[T]) One(ctx context.Context) (T, error)

func (*FinderExecutor[T]) Skip added in v0.2.2

func (f *FinderExecutor[T]) Skip(s int64) *FinderExecutor[T]

func (*FinderExecutor[T]) SortAsc added in v0.2.2

func (f *FinderExecutor[T]) SortAsc(field string) *FinderExecutor[T]

func (*FinderExecutor[T]) SortDesc added in v0.2.2

func (f *FinderExecutor[T]) SortDesc(field string) *FinderExecutor[T]

type InsertExecutor added in v0.2.2

type InsertExecutor[T Entity] struct {
	// contains filtered or unexported fields
}

func NewInsertExecutor added in v0.2.2

func NewInsertExecutor[T Entity](col *mongo.Collection) *InsertExecutor[T]

func (*InsertExecutor[T]) Save added in v0.2.2

func (i *InsertExecutor[T]) Save(ctx context.Context) error

func (*InsertExecutor[T]) SetItem added in v0.2.2

func (i *InsertExecutor[T]) SetItem(u ...T) *InsertExecutor[T]

type Op

type Op int

An Op represents a predicate operator.

const (
	// Comparision Query Operators
	OpEQ Op = iota
	OpNEQ
	OpGT
	OpGTE
	OpLT
	OpLTE
	OpIn
	OpNotIn
	// Logical Query Operators
	OpAnd
	OpNot
	OpNor
	OpOr
	// Element Query Operators
	OpExists
	OpType

	// Field Update Operators
	OpSet
	OpInc

	// Array Update Operatos
	OpPop
	OpPull
	OpPush
)

Predicate operators

type Predicate

type Predicate struct {
	Builder
	// contains filtered or unexported fields
}

func And

func And(pp ...*Predicate) *Predicate

func EQ

func EQ(field string, value interface{}) *Predicate

func GT

func GT(field string, value interface{}) *Predicate

func GTE

func GTE(field string, value interface{}) *Predicate

func In

func In(field string, value ...interface{}) *Predicate

func LT

func LT(field string, value interface{}) *Predicate

func LTE

func LTE(field string, value interface{}) *Predicate

func NEQ

func NEQ(field string, value interface{}) *Predicate

func Nor

func Nor(pp ...*Predicate) *Predicate

func NotIn

func NotIn(field string, value ...interface{}) *Predicate

func Or

func Or(pp ...*Predicate) *Predicate

func P

func P(fns ...func(*Builder)) *Predicate

func (*Predicate) EQ

func (p *Predicate) EQ(field string, value interface{}) *Predicate

func (*Predicate) GT

func (p *Predicate) GT(field string, value interface{}) *Predicate

func (*Predicate) GTE

func (p *Predicate) GTE(field string, value interface{}) *Predicate

func (*Predicate) In

func (p *Predicate) In(field string, value ...interface{}) *Predicate

func (*Predicate) LT

func (p *Predicate) LT(field string, value interface{}) *Predicate

func (*Predicate) LTE

func (p *Predicate) LTE(field string, value interface{}) *Predicate

func (*Predicate) NEQ

func (p *Predicate) NEQ(field string, value interface{}) *Predicate

func (*Predicate) Not

func (p *Predicate) Not(field string, p2 *Predicate) *Predicate

func (*Predicate) NotIn

func (p *Predicate) NotIn(field string, value ...interface{}) *Predicate

func (*Predicate) Query

func (p *Predicate) Query() bson.D

type UpdateExecutor added in v0.2.2

type UpdateExecutor[T Entity] struct {
	// contains filtered or unexported fields
}

func NewUpdateExecutor added in v0.2.2

func NewUpdateExecutor[T Entity](col *mongo.Collection) *UpdateExecutor[T]

func (*UpdateExecutor[T]) ByID added in v0.2.2

func (u *UpdateExecutor[T]) ByID(ctx context.Context, a primitive.ObjectID) (int64, error)

func (*UpdateExecutor[T]) Set added in v0.2.2

func (u *UpdateExecutor[T]) Set(name string, arg any) *UpdateExecutor[T]

Jump to

Keyboard shortcuts

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