querylang

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

README

Query language

Examples:

receiver:hello account:eoscanadacom action:transfer
avec un espace:
receiver: hello account:eoscanadacom action:transfer
receiver:"hello world" account: eoscanadacom action: transfer
data.from:eoscanadacom action:transfer account:eosio.token
(data.from:eoscanadacom OR data.to:eoscanadacom OR data.quantity:"12323.2323 EOS") action:transfer account:eosio.token
(data.from:eoscanadacom OR data.to:eoscanadacom) data.quantity:"12323.2323 EOS" action:transfer account:eosio.token
(data.from:eoscanadacom data.to:eoscanadacom) OR (data.to:eoscanadacom data.from:mamabob)
db.op:update db.scope:eoscanadacom db.table:accounts db.account:eosio.token
ram.account:eoscanadacom

The current basic language supports a first level of ands, and a single second level of parenthesized OR statements.

We keep it deliberately simple, so it can easily be implemented by some Go code, and translated to the bleve engine to fast query.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Keccak256

func Keccak256(data []byte) []byte

Keccak256 calculates and returns the Keccak256 hash of the input data.

Types

type AST

type AST struct {
	AndExpr []*SubGroup `parser:"@@ { @@ }" json:"ands"`
}

func Parse

func Parse(input string) (expr *AST, err error)

func (*AST) ApplyTransforms

func (a *AST) ApplyTransforms(transformer FieldTransformer) error

func (*AST) FindAllFieldNames

func (a *AST) FindAllFieldNames() []string

FindAllFieldNames returns all used field names in the AST. There is **NO** ordering on the elements, i.e. they might not come in the same order specified in the AST.

func (*AST) PurgeDeprecatedStatusField

func (a *AST) PurgeDeprecatedStatusField() error

func (*AST) ToBleve

func (a *AST) ToBleve() query.Query

type Field

type Field struct {
	Minus        string `parser:"@Minus?" json:"minus,omitempty"`
	Name         string `parser:"@Name Colon" json:"name"`
	QuotedString string `parser:"(  @QuotedString" json:"qstr,omitempty"`
	String       string `parser:" | @Name )" json:"str,omitempty"`
}

func (*Field) SetString

func (f *Field) SetString(in string)

func (*Field) StringValue

func (f *Field) StringValue() string

func (*Field) ToQuery

func (f *Field) ToQuery() query.Query

func (*Field) Transform

func (f *Field) Transform(transformer FieldTransformer) error

type FieldTransformer

type FieldTransformer interface {
	Transform(field *Field) error
}
var NoOpFieldTransformer FieldTransformer

type SubGroup

type SubGroup struct {
	Minus    string   `parser:"( @Minus?" json:"minus,omitempty"`
	OrFields []*Field `parser:"  LeftParenthesis @@ ( OrOperator @@ )+ RightParenthesis" json:"ors,omitempty"`
	AndField *Field   `parser:"  | @@ )" json:"and,omitempty"`
}

Jump to

Keyboard shortcuts

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