behold

package module
v0.0.0-...-da9d197 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2021 License: MIT Imports: 4 Imported by: 0

README

Behold is a generic querying and indexing layer for Go

Behold is based on the amazing work by Tim Shannon on BoltHold and BadgerHold, and adapts to any database by using interfaces.

The goal is to create a simple higher level interface that simplifies dealing with Go Types and finding data.

Queries

Queries are chain-able construct that filter out any data that doesn't match the criteria.

See also

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrAlreadySet

func ErrAlreadySet(field string, value interface{}) error

func ErrNotExported

func ErrNotExported(field string) error

func ErrNotPositive

func ErrNotPositive(field string) error

Types

type Criterion

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

Criterion is an operator and a value that a given field needs to match on

func Where

func Where(field string) *Criterion

Where starts a Query for specifying the criteria that an object needs to match to be returned in a Find result

func (*Criterion) Contains

func (c *Criterion) Contains(value interface{}) *Query

Contains tests if the current field is a slice that contains the passed in value

func (*Criterion) ContainsAll

func (c *Criterion) ContainsAll(values ...interface{}) *Query

ContainsAll tests if the current field is a slice that contains all of the passed in values

func (*Criterion) ContainsAny

func (c *Criterion) ContainsAny(values ...interface{}) *Query

ContainsAny tests if the current field is a slice that contains any of the passed in values

func (*Criterion) Eq

func (c *Criterion) Eq(value interface{}) *Query

Eq tests if the current field is Equal To the passed in value

func (*Criterion) Ge

func (c *Criterion) Ge(value interface{}) *Query

Ge tests if the current field is Greater Than or Equal To the passed in value

func (*Criterion) Gt

func (c *Criterion) Gt(value interface{}) *Query

Gt tests if the current field is Greater Than the passed in value

func (*Criterion) HasKey

func (c *Criterion) HasKey(value interface{}) *Query

HasKey tests if the current field has a map key matching the passed in value

func (*Criterion) HasPrefix

func (c *Criterion) HasPrefix(prefix string) *Query

HasPrefix will test if a field starts with the given string

func (*Criterion) HasSuffix

func (c *Criterion) HasSuffix(suffix string) *Query

HasSuffix will test if a field ends with the given string

func (*Criterion) In

func (c *Criterion) In(values ...interface{}) *Query

In tests if the current field is in the passed in values

func (*Criterion) IsNil

func (c *Criterion) IsNil() *Query

IsNil will test if the current field is equal to nil

func (*Criterion) Le

func (c *Criterion) Le(value interface{}) *Query

Le tests if the current field is Lower Than or Equal To the passed in value

func (*Criterion) Lt

func (c *Criterion) Lt(value interface{}) *Query

Lt tests if the current field is Lower Than the passed in value

func (*Criterion) Match

func (c *Criterion) Match(expression *regexp.Regexp) *Query

Match will test if the current field matches against a regular expression. The field value will be converted to string (%s) before testing

func (*Criterion) Ne

func (c *Criterion) Ne(value interface{}) *Query

Ne tests if the current field is Not Equal To the passed in value

type Query

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

Query is a chained collection of criteria of which an object needs to match to be returned. An Empty query matches against all records.

func (*Query) And

func (q *Query) And(field string) *Criterion

And creates another set of criterior that needs to apply to a query

func (*Query) IsEmpty

func (q *Query) IsEmpty() bool

func (*Query) Limit

func (q *Query) Limit(amount int) *Query

Limit sets the maximum number of records that can be returned by a query. Setting Limit multiple times or to a negative value will panic.

func (*Query) Reverse

func (q *Query) Reverse() *Query

Reverse will reverse the current result set. Useful with SortBy

func (*Query) Skip

func (q *Query) Skip(amount int) *Query

Skip skips a number of records that match all the rest of the query criteria, and aren't included in the result set. Setting Skip multiple times or to a negative value will panic.

type Store

type Store interface{}

type Transaction

type Transaction interface{}

Jump to

Keyboard shortcuts

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