func (aq *AqlStruct) Filter(f ...interface{}) *AqlStruct {
	if len(f) == 0 {
		return aq
	}
	var any bool
	var fil2 AqlFilter
	var key string
	var jump int
	switch f[len(f)-1].(type) {
	case bool:
		any = f[len(f)-1].(bool)
		switch f[0].(type) {
		case string:
			fil2.DefaultKey = f[0].(string)
			key = fil2.DefaultKey
			jump++
		}
	default:
		any = false
	}
	fil2.Any = any
	for _, i := range f {
		if jump > 0 {
			jump--
			continue
		}
		var fil AqlFilter
		switch i.(type) {
		case []byte:
			s := string(i.([]byte))
			if isJSON(s) {
				fil = FilterJSON(s)
			} else {
				fil.Custom = s
			}
		case string:
			if isJSON(i.(string)) {
				fil = FilterJSON(i.(string))
			} else {
				fil.Custom = i.(string)
			}
		case AqlFilter:
			fil = i.(AqlFilter)
		case AqlFunction:
			if any {
				fil2.Functions = append(fil2.Functions, i.(AqlFunction))
				continue
			} else {
				fil.DefaultKey = key
				fil.Functions = append(fil.Functions, i.(AqlFunction))
			}
		case Filter:
			if any {
				fil2.Filters = append(fil2.Filters, i.(Filter))
				continue
			} else {
				fil.DefaultKey = key
				fil.Filters = append(fil.Filters, i.(Filter))
			}
		default:
			continue
		}
		aq.lines = append(aq.lines, fil)
	}
	if len(fil2.Filters) > 0 || len(fil2.Functions) > 0 {
		aq.lines = append(aq.lines, fil2)
	}
	return aq
}
Aql filter add Filter()  to AqlQuery
Could be use like:
- Filter(custom ... string)
example:
Filter("u.name == 'Diego' && u.age > 21")
out:
FILTER u.name == 'Diego' && u.age > 21
- Filter(key string,fil ... Filter || AqlFunction, any bool)
example:
Filter("u",Fil("sum","eq",213),Fil("age","gt",21),true)
out:
FILTER u.sum == 213 || u.age > 21
Filter("u",Fil("sum","eq",213),FilField("id","==","adm.id"),false)
out:
FILTER u.sum == 213
FILTER u.id == adm.id
Filter("u",Fil("sum","eq",213),FilField("id","==","adm.id"),false)
out:
FILTER u.sum == 213
FILTER u.id == adm.id
Filter("u",Fun("LIKE",Atr("u","name"),"di%",true)
out:
FILTER u.age > 21  ||  LIKE(u.name,'di%',true)
-FILTER(jsonFilter string)
example:
Filter(`{ "key" : "u" , "filters": [{ "name": "name", "like": "gt", "val": "die%" },{ "name": "status", "op": "eq", "val":"A"}] }`)
out:
FILTER (IS_NULL(u.name) == false && LIKE(u.name,'die%',true)) && u.status == 'A'
Filter(`{ "key" : "u" , "filters": [{ "name": "status", "op": "==", "val": "P" },{ "name": "status", "op": "eq", "val":"A"}], "any" : true }`)
out:
FILTER u.status == 'P' || u.status == 'A'
Filter(`{ "key" : "u" , "filters": [{ "name": "id", "op": "==", "field": "adm.id" },{ "name": "status", "op": "eq", "val":"A"}], "any" : true }`)
out:
FILTER u.id == adm.id || u.status == 'A'
package aranGO
import (
	"encoding/json"
	"errors"
	"strconv"
	"strings"
)
type Obj map[string]interface{}
type List []interface{}
func (l List) String() string {
	code := "["
	var aux []string
	for _, i := range l {
		var pair string
		switch i.(type) {
		case string:
			pair += "'" + i.(string) + "'"
		case int:
			pair += strconv.Itoa(i.(int))
		case int32:
			pair += strconv.FormatInt(i.(int64), 10)
		case int64:
			pair += strconv.FormatInt(i.(int64), 10)
		case float64:
			pair += strconv.FormatFloat(i.(float64), 'f', 6, 64)
		default:
			pair += " "
		}
		aux = append(aux, pair)
	}
	code += strings.Join(aux, ",") + "]"
	return code
}
func (ob Obj) String() string {
	code := "{ "
	var aux []string
	for key, val := range ob {
		var pair string
		pair += key + " : "
		switch val.(type) {
		case Var:
			pair += val.(Var).String()
		case string:
			pair += "'" + val.(string) + "'"
		case int32:
			pair += strconv.FormatInt(val.(int64), 10)
		case int64:
			pair += strconv.FormatInt(val.(int64), 10)
		case AqlStruct, *AqlStruct:
			pair += "( " + val.(*AqlStruct).Generate() + " )"
		case AqlFunction:
			pair += val.(*AqlFunction).Generate()
		default:
			pair += genValue(val)
		}
		aux = append(aux, pair)
	}
	code += strings.Join(aux, ",") + " }"
	return code
}
type Var struct {
	Obj  string
	Name string
}
func Col(name string) Var {
	var v Var
	v.Obj = name
	return v
}
func Atr(obj, name string) Var {
	var v Var
	v.Obj = obj
	v.Name = name
	return v
}
func (v Var) String() string {
	if v.Obj != "" && v.Name == "" {
		return v.Obj
	}
	if v.Obj != "" && v.Name != "" {
		q := v.Obj + "." + v.Name
		return q
	}
	return ""
}
type Query struct {
	Aql string `json:"query,omitempty"`
	Count    bool                   `json:"count,omitempty"`
	BindVars map[string]interface{} `json:"bindVars,omitempty"`
	Options  map[string]interface{} `json:"options,omitempty"`
	Validate bool   `json:"-"`
	ErrorMsg string `json:"errorMessage,omitempty"`
}
func NewQuery(query string) *Query {
	var q Query
	q.Options = make(map[string]interface{})
	q.BindVars = make(map[string]interface{})
	if query == "" {
		return &q
	} else {
		q.Aql = query
		return &q
	}
}
func (q *Query) SetFullCount(count bool) {
	q.Options["fullCount"] = count
}
func (q *Query) Modify(query string) error {
	if query == "" {
		return errors.New("query must not be empty")
	} else {
		q.Aql = query
		return nil
	}
}
func (q *Query) MustCheck() {
	q.Validate = true
	return
}
type AqlStructer interface {
	Generate() string
}
type AqlStruct struct {
	lines []AqlStructer
	nlopp uint
	vars  []string
	err   bool
}
func (aq *AqlStruct) Generate() string {
	if len(aq.lines) == 0 {
		return ""
	}
	var code string
	for _, aql := range aq.lines {
		code += `
            ` + aql.Generate()
	}
	return code
}
func NewAqlStruct() *AqlStruct {
	var aq AqlStruct
	return &aq
}
func (aq *AqlStruct) Execute(db *Database) (*Cursor, error) {
	q := NewQuery(aq.Generate())
	c, err := db.Execute(q)
	return c, err
}
func (aq *AqlStruct) subStruct() *AqlStruct {
	var substruct AqlStruct
	if len(aq.vars) > 0 {
		for _, v := range aq.vars {
			substruct.vars = append(substruct.vars, v)
		}
		return &substruct
	} else {
		panic("getting substruct from empty struct")
	}
}
type aqlFor struct {
	in interface{}
	v  string
}
func (aqf aqlFor) Generate() string {
	code := ""
	if aqf.v == "" {
		return code
	}
	code += "FOR " + aqf.v + " IN "
	switch aqf.in.(type) {
	case string:
		code += aqf.in.(string)
	case *AqlFunction:
		code += aqf.in.(AqlFunction).Generate()
	case []string:
		code += "[" + strings.Join(aqf.in.([]string), ", ") + "]"
	case List:
		code += aqf.in.(List).String()
	default:
		return code
	}
	return code
}
func (aq *AqlStruct) For(v string, in interface{}) *AqlStruct {
	var afor aqlFor
	afor.v = v
	afor.in = in
	aq.lines = append(aq.lines, afor)
	return aq
}
type aqlReturn struct {
	Atr Var
	Var string
	Ret Obj
}
func (ar aqlReturn) Generate() string {
	code := "RETURN "
	if ar.Var != "" {
		code += ar.Var
	} else {
		if len(ar.Ret) > 0 {
			code += ar.Ret.String()
		} else {
			code += ar.Atr.String()
		}
	}
	return code
}
func (aq *AqlStruct) Return(view interface{}) *AqlStruct {
	var ret aqlReturn
	switch view.(type) {
	case string:
		if view.(string) == "" {
			return aq
		} else {
			ret.Var = view.(string)
		}
	case Obj:
		ret.Ret = view.(Obj)
	case Var:
		ret.Atr = view.(Var)
	default:
		return aq
	}
	aq.lines = append(aq.lines, ret)
	return aq
}