Skip to content

Latest commit

 

History

History
313 lines (221 loc) · 7.84 KB

api.md

File metadata and controls

313 lines (221 loc) · 7.84 KB

talkback

import "github.com/Arsfiqball/talkback"

Index

Constants

const (
    OpIsNull    = "isnull"    // IS NULL
    OpEq        = "eq"        // EQUALS
    OpNe        = "ne"        // NOT EQUALS
    OpGt        = "gt"        // GREATER THAN
    OpLt        = "lt"        // LESS THAN
    OpGte       = "gte"       // GREATER THAN OR EQUALS
    OpLte       = "lte"       // LESS THAN OR EQUALS
    OpContain   = "contain"   // CONTAINS
    OpNcontain  = "ncontain"  // NOT CONTAINS
    OpContains  = "contains"  // CONTAINS CASE SENSITIVE
    OpNcontains = "ncontains" // NOT CONTAINS CASE SENSITIVE
    OpIn        = "in"        // IN
    OpNin       = "nin"       // NOT IN
)

Variables

var (
    ErrInvalidField   = errors.New("invalid field")
    ErrInvalidOp      = errors.New("invalid op")
    ErrInvalidPreload = errors.New("invalid preload")
)

func SqlConvertBool

func SqlConvertBool(value string) (interface{}, error)

SqlConvertString is a TypeConverter that converts a string to a string.

func SqlConvertDate

func SqlConvertDate(value string) (interface{}, error)

SqlConvertString is a TypeConverter that converts a string to a string.

func SqlConvertDateTime

func SqlConvertDateTime(value string) (interface{}, error)

SqlConvertString is a TypeConverter that converts a string to a string.

func SqlConvertFloat

func SqlConvertFloat(value string) (interface{}, error)

SqlConvertString is a TypeConverter that converts a string to a string.

func SqlConvertISO8601

func SqlConvertISO8601(value string) (interface{}, error)

SqlConvertString is a TypeConverter that converts a string to a string.

func SqlConvertInt

func SqlConvertInt(value string) (interface{}, error)

SqlConvertString is a TypeConverter that converts a string to a string.

func SqlConvertString

func SqlConvertString(value string) (interface{}, error)

SqlConvertString is a TypeConverter that converts a string to a string.

func SqlConvertTime

func SqlConvertTime(value string) (interface{}, error)

SqlConvertString is a TypeConverter that converts a string to a string.

func ToSql

func ToSql(table string, query Query, translations SqlTranslations) (string, []interface{}, error)

func ToSqlGroup

func ToSqlGroup(query Query, translations SqlTranslations) (string, error)

ToSqlGroup converts a Query to a SQL GROUP BY statement.

func ToSqlGroupSlice

func ToSqlGroupSlice(query Query, translations SqlTranslations) ([]string, error)

ToSqlGroupSlice converts a Query to a slice of SQL GROUP BY statements.

func ToSqlLimit

func ToSqlLimit(query Query) (int, error)

ToSqlLimit converts a Query to a SQL LIMIT statement.

func ToSqlOffset

func ToSqlOffset(query Query) (int, error)

ToSqlOffset converts a Query to a SQL OFFSET statement.

func ToSqlOrderBy

func ToSqlOrderBy(query Query, translations SqlTranslations) (string, error)

ToSqlOrderBy converts a Query to a SQL ORDER BY statement.

func ToSqlOrderBySlice

func ToSqlOrderBySlice(query Query, translations SqlTranslations) ([]string, error)

ToSqlOrderBySlice converts a Query to a slice of SQL ORDER BY statements.

func ToSqlPreload

func ToSqlPreload(query Query, preloadable SqlPreloadable) ([]string, error)

ToSqlPreload converts a Query to a SQL preload statement.

func ToSqlSelect

func ToSqlSelect(query Query, translations SqlTranslations) (string, error)

ToSqlSelect converts a Query to a SQL SELECT statement.

func ToSqlSelectSlice

func ToSqlSelectSlice(query Query, translations SqlTranslations) ([]string, error)

ToSqlSelectSlice converts a Query to a slice of SQL SELECT statements.

func ToSqlWhere

func ToSqlWhere(query Query, translations SqlTranslations) (string, []interface{}, error)

ToSqlWhere converts a Query to a SQL WHERE statement.

type Condition

Op is a string representing a valid operation.

type Condition struct {
    Field  string   // Field is the name of the field to filter on.
    Op     string   // Op is the operation to perform.
    Values []string // Values is a list of values to filter on.
}

func (Condition) Valid

func (c Condition) Valid() bool

Valid returns true if the condition is valid.

type Query

Query is a query to filter on.

type Query struct {
    Conditions  []Condition
    With        []string
    Group       []string
    Accumulator []string
    Sort        []Sort
    Limit       int
    Skip        int
}

func FromQueryString

func FromQueryString(qs string) (Query, error)

FromQueryString returns a Query from a query string.

func FromURLValues

func FromURLValues(params url.Values) (Query, error)

FromQueryString returns a Query from a query string.

type Sort

Query is a query to filter on.

type Sort struct {
    Field   string
    Reverse bool
}

type SqlFieldTranslation

SqlFieldTranslation is a translation from a field name to a SQL field.

type SqlFieldTranslation struct {
    Column        string
    Alias         string
    TypeConverter func(value string) (interface{}, error)
}

type SqlPreloadable

SqlPreloadable is a map of preloads (key) and their corresponding model (value).

type SqlPreloadable map[string]string

type SqlTranslations

SqlTranslations is a map of field names to SQL translations.

type SqlTranslations map[string]SqlFieldTranslation

Generated by gomarkdoc