query

package
v0.0.0-...-267bd09 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2016 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package query provides a way to build queries from schema.Fields and DNF notations

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CNF

type CNF []DNF

CNF is a slice of DNF that will be ANDed together

type Conjunction

type Conjunction []Proposition

Conjunction is a slice of Proposition to be ANDed together

type ConjunctionString

type ConjunctionString []PropositionString

ConjunctionString is a slice of PropositionString to be considered as joined together by a AND

type DNF

type DNF Disjunction

DNF is a single Disjunction

func DnfStringToDNF

func DnfStringToDNF(dnfString DNFString, tables []*schema.Table) (DNF, error)

DnfStringToDNF is a helper function particularly useful for people who need to receive a JSON payload from somewhere and convert it to a DNF ready to be used in a Select().Where() clause

type DNFString

type DNFString DisjunctionString

DNFString is a single DisjunctionString

type Disjunction

type Disjunction []Conjunction

Disjunction is a slice of Conjunction that will be ORed together

type DisjunctionString

type DisjunctionString []ConjunctionString

DisjunctionString is a slice of ConjunctionString that will be joined together with OR

type Proposition

type Proposition struct {
	Field    schema.Field
	Operator string
	Value    interface{}
}

Proposition is a triplet with schema.Field, operator, value(s)

type PropositionString

type PropositionString struct {
	Field    string      `json:"field"`
	Operator string      `json:"op"`
	Value    interface{} `json:"val"`
	Table    string      `json:"table"`
}

PropositionString is a quadruplet with field, operator, value, table all as strings

type SearchPart

type SearchPart struct {
	Limit     int       `json:"limit"`
	Offset    int       `json:"offset"`
	DNFString DNFString `json:"dnf"`
}

SearchPart is a structure that expresses a part of a SELECT clause after the WHERE (ie: a DNF for all OR/AND/(col, op, value) + limit & offset

type Selectable

type Selectable interface {
	Where(DNF) (Selectable, error)
	Limit(int) (Selectable, error)
	Offset(int) (Selectable, error)
	Count() Selectable
	Values([]map[schema.Field]interface{}) (Selectable, error)
	Compile() (string, []interface{}, error)
	Join(schema.Field, schema.Field) (Selectable, error)
}

Selectable exposes Where, Limit & Offset methods that all return another selectable the Compile method returns a string that expresses your select statement

func Delete

func Delete(table schema.Table) (Selectable, error)

Delete is a function the produces a Selectable to delete from a table

func Insert

func Insert(table schema.Table) (Selectable, error)

func Select

func Select(fields ...schema.Field) (Selectable, error)

Select is a function that produces a Selectable from a series of Schema Fields

func Update

func Update(table schema.Table) (Selectable, error)

Jump to

Keyboard shortcuts

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