sql

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2025 License: AGPL-3.0 Imports: 12 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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