package module
Version: v0.2.2 Latest Latest

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

Go to latest
Published: Dec 2, 2019 License: MIT Imports: 4 Imported by: 0


querybuilder for Appengine Datastore




This section is empty.


View Source
var Operators = []Ope{LT, LTE, GT, GTE, EQ}


func BuildOperatorMap

func BuildOperatorMap(opes []Ope) map[string]Ope

func ReflectWalkIn

func ReflectWalkIn(base *reflect.Value, field, sep string, f func(*reflect.Value) error) error

func ReflectWalkInImpl

func ReflectWalkInImpl(curr *reflect.Value, fields []string, f func(*reflect.Value) error) error


type Assigner

type Assigner struct {
	Field string      `json:"field"`
	Value interface{} `json:"value"`

func AssignerFor

func AssignerFor(field string, value interface{}) *Assigner

func (*Assigner) Do

func (a *Assigner) Do(entity interface{}) error

type Assigners

type Assigners []*Assigner

func (Assigners) Assign

func (s Assigners) Assign(entity interface{}) error

func (Assigners) AssignAll

func (s Assigners) AssignAll(entities interface{}) error

type Condition

type Condition struct {
	Field string      `json:"field"`
	Ope   Ope         `json:"ope"`
	Value interface{} `json:"value"`

func (*Condition) Call

func (c *Condition) Call(q *datastore.Query) *datastore.Query

func (*Condition) OriginalTypeValue added in v0.2.1

func (c *Condition) OriginalTypeValue() interface{}

type ConditionPredict

type ConditionPredict func(*Condition) bool

type Conditions

type Conditions []*Condition

func (Conditions) Call

func (Conditions) HasMultipleIneqFields

func (s Conditions) HasMultipleIneqFields() bool

func (Conditions) IneqFields

func (s Conditions) IneqFields() Strings

type Ope

type Ope string
const (
	LT  Ope = "<"
	LTE Ope = "<="
	GT  Ope = ">"
	GTE Ope = ">="
	EQ  Ope = "="

func (Ope) String

func (ope Ope) String() string

type QueryBuilder

type QueryBuilder struct {
	Fields     Strings         `json:"fields,omitempty"`
	Ignored    Strings         `json:"ignored,omitempty"`
	SortFields Strings         `json:"sort_fields,omitempty"`
	Conditions Conditions      `json:"conditions,omitempty"`
	Filters    []*ValuedFilter `json:"filters,omitempty"`
	Assigns    Assigners       `json:"assigns,omitempty"`

func New

func New(fields ...string) *QueryBuilder

func (*QueryBuilder) AddCondition

func (qb *QueryBuilder) AddCondition(field string, ope Ope, value interface{}) *QueryBuilder

func (*QueryBuilder) AddIntFilter

func (qb *QueryBuilder) AddIntFilter(name string, value int) *QueryBuilder

func (*QueryBuilder) AddSort

func (qb *QueryBuilder) AddSort(field string) *QueryBuilder

func (*QueryBuilder) Asc

func (qb *QueryBuilder) Asc(field string) *QueryBuilder

func (*QueryBuilder) Build

func (*QueryBuilder) BuildForCount

func (qb *QueryBuilder) BuildForCount(q *datastore.Query) *datastore.Query

func (*QueryBuilder) BuildForList

func (qb *QueryBuilder) BuildForList(q *datastore.Query) (*datastore.Query, Assigners)

func (*QueryBuilder) Desc

func (qb *QueryBuilder) Desc(field string) *QueryBuilder

func (*QueryBuilder) Eq

func (qb *QueryBuilder) Eq(field string, value interface{}) *QueryBuilder

func (*QueryBuilder) Gt

func (qb *QueryBuilder) Gt(field string, value interface{}) *QueryBuilder

func (*QueryBuilder) Gte

func (qb *QueryBuilder) Gte(field string, value interface{}) *QueryBuilder

func (*QueryBuilder) Ineq

func (qb *QueryBuilder) Ineq(ope Ope, field string, value interface{}) *QueryBuilder

func (*QueryBuilder) Limit

func (qb *QueryBuilder) Limit(v int) *QueryBuilder

func (*QueryBuilder) Lt

func (qb *QueryBuilder) Lt(field string, value interface{}) *QueryBuilder

func (*QueryBuilder) Lte

func (qb *QueryBuilder) Lte(field string, value interface{}) *QueryBuilder

func (*QueryBuilder) Offset

func (qb *QueryBuilder) Offset(v int) *QueryBuilder

func (*QueryBuilder) ProjectFields

func (qb *QueryBuilder) ProjectFields() Strings

func (*QueryBuilder) Starts

func (qb *QueryBuilder) Starts(field, value string) *QueryBuilder

type QueryFilter

type QueryFilter func(*datastore.Query) *datastore.Query

type Strings

type Strings []string

func (Strings) Except

func (s Strings) Except(v Strings) Strings

func (Strings) Filter

func (s Strings) Filter(f func(Strings, string) bool) Strings

func (Strings) Has

func (s Strings) Has(v string) bool

func (Strings) Uniq

func (s Strings) Uniq() Strings

type ValuedFilter

type ValuedFilter struct {
	Name     string `json:"name"`
	IntValue int    `json:"value"`

func (*ValuedFilter) Call

func (vf *ValuedFilter) Call(q *datastore.Query) *datastore.Query


Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL