mspecification

package
v0.0.0-...-5d22fbd Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseSpecification

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

BaseSpecification is the base specification for all mongo specifications.

func NewBaseSpecification

func NewBaseSpecification() *BaseSpecification

NewBaseSpecification creates a new base specification.

func (*BaseSpecification) FilterByID

func (b *BaseSpecification) FilterByID(id string) specification.Set

FilterByID adds a filter to the specification by ID (primary key).

func (*BaseSpecification) FilterEntry

func (b *BaseSpecification) FilterEntry(attributes map[string]interface{}) specification.Set

Filter adds filters to the specification.

func (*BaseSpecification) GetPreloadIndex

func (b *BaseSpecification) GetPreloadIndex(field string) int

func (*BaseSpecification) GreaterThan

func (b *BaseSpecification) GreaterThan(field string, value interface{}) specification.Set

func (*BaseSpecification) LessThan

func (b *BaseSpecification) LessThan(field string, value interface{}) specification.Set

func (*BaseSpecification) Limit

func (b *BaseSpecification) Limit(limit int) specification.Set

Limit adds a limit to the specification.

func (*BaseSpecification) NeedsPreload

func (b *BaseSpecification) NeedsPreload(field string) (bool, []bson.M)

NeedsPreload requires overriding in the child.

func (*BaseSpecification) PreQueryHook

func (b *BaseSpecification) PreQueryHook()

PreQueryHook is called before the query is executed It's either empty or overridden by the child.

func (*BaseSpecification) Prefetch

func (b *BaseSpecification) Prefetch(preload ...string) specification.Set

Prefetch adds preloads to the specification.

func (*BaseSpecification) Query

func (b *BaseSpecification) Query() interface{}

Query returns the query to be used in the database Order of operations: 1. PreQueryHook 2. Filters 3. Preload 4. PostFilters 5. Sort 6. Limit.

func (*BaseSpecification) ReplacePreload

func (b *BaseSpecification) ReplacePreload(field string, preload []bson.M) specification.Set

func (*BaseSpecification) Sort

func (b *BaseSpecification) Sort(sortBy string, sortOrder sort.Order) specification.Set

Sort adds a sort to the specification.

func (*BaseSpecification) WithContext

func (b *BaseSpecification) WithContext(ctx context.Context) specification.Set

WithContext adds a context to the specification.

type BsonO

type BsonO interface {
	bson.M | bson.A | bson.D
}

type ExtendedSpecifications

type ExtendedSpecifications interface {
	specification.Set
	PreQueryHook()
	NeedsPreload(field string) (bool, []bson.M)
}

Jump to

Keyboard shortcuts

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