provision: github.com/digitalrebar/provision/backend/index Index | Files

package index

import "github.com/digitalrebar/provision/backend/index"

Index

Package Files

index.go

func CheckUnique Uses

func CheckUnique(s models.Model, objs []models.Model) error

func MakeBaseIndexes Uses

func MakeBaseIndexes(m models.Model) map[string]Maker

type Fake Uses

type Fake string

func (Fake) Fill Uses

func (f Fake) Fill()

func (Fake) Key Uses

func (f Fake) Key() string

func (Fake) Prefix Uses

func (f Fake) Prefix() string

type FakeValid Uses

type FakeValid bool

func (FakeValid) ClearValidation Uses

func (f FakeValid) ClearValidation()

func (FakeValid) Fill Uses

func (f FakeValid) Fill()

func (FakeValid) HasError Uses

func (f FakeValid) HasError() error

func (FakeValid) IsAvailable Uses

func (f FakeValid) IsAvailable() bool

func (FakeValid) IsReadOnly Uses

func (f FakeValid) IsReadOnly() bool

func (FakeValid) Key Uses

func (f FakeValid) Key() string

func (FakeValid) Prefix Uses

func (f FakeValid) Prefix() string

func (FakeValid) Useable Uses

func (f FakeValid) Useable() bool

func (FakeValid) Validate Uses

func (f FakeValid) Validate()

type Filler Uses

type Filler func(string) (models.Model, error)

Filler takes a value from a query parameter and plugs it into the appropriate slot in the proper model for an index. It is responsible for doing whatever conversion is needed to translate from a string to the appropriate type for the index.

type Filter Uses

type Filter func(*Index) (*Index, error)

Filter is a function that takes an index, does stuff with it, and returns another index

func All Uses

func All(filters ...Filter) Filter

All returns a filter that returns an index tha contains items that pass all the filters.

func Any Uses

func Any(filters ...Filter) Filter

Any returns a filter that returns an index that contains items that pass any of the filters. There may be duplicate items.

func Between Uses

func Between(lower, upper string) Filter

func Eq Uses

func Eq(ref string) Filter

Eq returns a filter that will keep all the items that are equal to the current comparators.

func Except Uses

func Except(lower, upper string) Filter

func Gt Uses

func Gt(ref string) Filter

Gt returns a filter that will keep all the items that are greater-than the current comparators

func Gte Uses

func Gte(ref string) Filter

Gte returns a filter that will keep all the items that are greater than or equal to the current comparators

func Limit Uses

func Limit(num int) Filter

Limit returns a filter that returns the first n items

func Lt Uses

func Lt(ref string) Filter

Lt returns a filter that will keep all items that are less than the current comparators

func Lte Uses

func Lte(ref string) Filter

Lte returns a filter that will keep all the items that are less than or equal to the current comparators.

func Native Uses

func Native() Filter

Native returns a filter that will sort an Index based on key order.

func Ne Uses

func Ne(ref string) Filter

Ne returns a filter that will keep all the items that are not equal to the current comparators.

func Offset Uses

func Offset(num int) Filter

Offset returns a filter that returns all but the first n items

func Resort Uses

func Resort() Filter

Resort sorts the index with the same function passed in to the most recent Sort filter.

func Reverse Uses

func Reverse() Filter

Reverse returns a filter that will reverse an index.

func Select Uses

func Select(t Test) Filter

Select returns a filter that picks all items that match the passed Test. It does not rely on the Index being sorted in any particular order.

func Sort Uses

func Sort(m Maker) Filter

func Subset Uses

func Subset(lower, upper Test) Filter

Subset returns a filter that will sort an index based on the lower bound test and the upper bound tests, which correspond to the gte and gt functions that SetComparators takes.

type Index Uses

type Index struct {
    Maker
    // contains filtered or unexported fields
}

Index declares a struct field that can be indexed for a given Model, along with the function that should be used to sort things in key order. Unless otherwise indicated, any methods that act on an Index return a new Index with its own reference to indexed items.

func Create Uses

func Create(objs []models.Model) *Index

func New Uses

func New(objs []models.Model) *Index

New returns a new Index that is populated with a copy of the passed-in objs.

func (*Index) Add Uses

func (i *Index) Add(items ...models.Model) error

func (*Index) Count Uses

func (i *Index) Count() int

func (*Index) Empty Uses

func (i *Index) Empty() bool

func (*Index) Find Uses

func (i *Index) Find(key string) models.Model

func (*Index) Items Uses

func (i *Index) Items() []models.Model

Items returns the current items the index has filtered.

func (*Index) Remove Uses

func (i *Index) Remove(items ...models.Model) error

type Indexer Uses

type Indexer interface {
    Indexes() map[string]Maker
}

type Less Uses

type Less func(models.Model, models.Model) bool

Less is a function that tests to see if the first item is less than the second item.

type Maker Uses

type Maker struct {
    Unique bool
    Type   string
    Less   Less      `json:"-"`
    Tests  TestMaker `json:"-"`
    Fill   Filler    `json:"-"`
    // contains filtered or unexported fields
}

Maker is used to hold reference functions for a specific index on a specific struct. The functions are:

Less, which compares one item in the index with another, and returns true if it is. It is used to sort values in the index.

Tests, which takes an example item of the type indexed with the appropriate reference field filled in. It returns a pair of functions that satisfy the constraints of the SetComparators filter and the Subset filter.

Fill, which takes a string from a query parameter and turns it into a models.Model that has the appropriate slot filled.

func Make Uses

func Make(unique bool, t string, less Less, maker TestMaker, filler Filler) Maker

Make takes a Less function, a TestMaker function, and a Filler function and returns a Maker. t is a textual type identifier for docs/helps

func MakeKey Uses

func MakeKey() Maker

type Test Uses

type Test func(models.Model) bool

Tester is a function that tests to see if an item matches a condition

type TestMaker Uses

type TestMaker func(models.Model) (Test, Test)

TestMaker is a function that takes a reference object and spits out appropriate Tests for gte and gt, in that order.

Package index imports 4 packages (graph) and is imported by 3 packages. Updated 2017-12-02. Refresh now. Tools for package owners.