sql

package
v0.0.0-...-7ac09b0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddField

func AddField(field func() *Field)

func BuildCriteria

func BuildCriteria(clauses ...*WhereClause) *imap.SearchCriteria

func GetFieldsFromMessage

func GetFieldsFromMessage(m *email.Message, fields []*Field) map[string]interface{}

func Query

func Query(c *imapclient.Client, query string, messageCh chan<- *email.Message) error

func Select

func Select(c *imapclient.Client, fields []*Field, from string, limit int64, messageCh chan<- *email.Message, clauses ...*WhereClause) error

func TriageMessage

func TriageMessage(m *email.Message, conds ...*WhereClause) bool

Types

type Clause

type Clause string
const (
	SELECT Clause = "SELECT"
	INSERT Clause = "INSERT"
	UPDATE Clause = "UPDATE"
	DELETE Clause = "DELETE"
)

type Field

type Field struct {
	Name              string
	Aliases           []string
	AllowedOperators  []Operator
	Selectable        bool
	Searchable        bool
	Valid             bool
	Reason            string
	GetValue          func(m *email.Message) interface{}
	ApplyFetchOptions func(options *imap.FetchOptions)
	ApplyCriteria     func(criteria *imap.SearchCriteria, clause *WhereClause)
	Triage            func(m *email.Message, clause *WhereClause) bool
}

func GetField

func GetField(name string) *Field

func GetFieldsFromQuery

func GetFieldsFromQuery(query string) []*Field

func ListFields

func ListFields() []*Field

func (*Field) IsAllowedOperator

func (f *Field) IsAllowedOperator(op Operator) bool

func (*Field) SetInvalid

func (f *Field) SetInvalid(reason string)

func (*Field) SetInvalidOperator

func (f *Field) SetInvalidOperator(op Operator)

func (*Field) String

func (f *Field) String() string

func (*Field) Validate

func (f *Field) Validate() error

type Operator

type Operator string
const (
	Equals    Operator = "="
	Unequals  Operator = "!="
	Like      Operator = "LIKE"
	Less      Operator = "<"
	Greater   Operator = ">"
	LessEq    Operator = "<="
	GreaterEq Operator = ">="
	In        Operator = "IN"
)

type ParseResult

type ParseResult struct {
	Clause  string
	Fields  []*Field
	From    string
	Mailbox string
	Conds   []*WhereClause
	Limit   int64
}

func ParseQuery

func ParseQuery(sql string) (result *ParseResult, err error)

type Table

type Table string
const (
	Emails Table = "emails"
)

type WhereClause

type WhereClause struct {
	Field    *Field
	Operator Operator
	Value    []string
}

func (*WhereClause) ApplyCriteria

func (w *WhereClause) ApplyCriteria(criteria *imap.SearchCriteria)

func (*WhereClause) GetKey

func (w *WhereClause) GetKey() string

func (*WhereClause) GetValue

func (w *WhereClause) GetValue() string

GetValue returns the first value of the clause.

func (*WhereClause) String

func (w *WhereClause) String() string

String returns the string representation of the clause.

Jump to

Keyboard shortcuts

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