import "github.com/Arsfiqball/talkback"
- Constants
- Variables
- func SqlConvertBool(value string) (interface{}, error)
- func SqlConvertDate(value string) (interface{}, error)
- func SqlConvertDateTime(value string) (interface{}, error)
- func SqlConvertFloat(value string) (interface{}, error)
- func SqlConvertISO8601(value string) (interface{}, error)
- func SqlConvertInt(value string) (interface{}, error)
- func SqlConvertString(value string) (interface{}, error)
- func SqlConvertTime(value string) (interface{}, error)
- func ToSql(table string, query Query, translations SqlTranslations) (string, []interface{}, error)
- func ToSqlGroup(query Query, translations SqlTranslations) (string, error)
- func ToSqlGroupSlice(query Query, translations SqlTranslations) ([]string, error)
- func ToSqlLimit(query Query) (int, error)
- func ToSqlOffset(query Query) (int, error)
- func ToSqlOrderBy(query Query, translations SqlTranslations) (string, error)
- func ToSqlOrderBySlice(query Query, translations SqlTranslations) ([]string, error)
- func ToSqlPreload(query Query, preloadable SqlPreloadable) ([]string, error)
- func ToSqlSelect(query Query, translations SqlTranslations) (string, error)
- func ToSqlSelectSlice(query Query, translations SqlTranslations) ([]string, error)
- func ToSqlWhere(query Query, translations SqlTranslations) (string, []interface{}, error)
- type Condition
- type Query
- type Sort
- type SqlFieldTranslation
- type SqlPreloadable
- type SqlTranslations
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
)
var (
ErrInvalidField = errors.New("invalid field")
ErrInvalidOp = errors.New("invalid op")
ErrInvalidPreload = errors.New("invalid preload")
)
func SqlConvertBool(value string) (interface{}, error)
SqlConvertString is a TypeConverter that converts a string to a string.
func SqlConvertDate(value string) (interface{}, error)
SqlConvertString is a TypeConverter that converts a string to a string.
func SqlConvertDateTime(value string) (interface{}, error)
SqlConvertString is a TypeConverter that converts a string to a string.
func SqlConvertFloat(value string) (interface{}, error)
SqlConvertString is a TypeConverter that converts a string to a string.
func SqlConvertISO8601(value string) (interface{}, error)
SqlConvertString is a TypeConverter that converts a string to a string.
func SqlConvertInt(value string) (interface{}, error)
SqlConvertString is a TypeConverter that converts a string to a string.
func SqlConvertString(value string) (interface{}, error)
SqlConvertString is a TypeConverter that converts a string to a string.
func SqlConvertTime(value string) (interface{}, error)
SqlConvertString is a TypeConverter that converts a string to a string.
func ToSql(table string, query Query, translations SqlTranslations) (string, []interface{}, error)
func ToSqlGroup(query Query, translations SqlTranslations) (string, error)
ToSqlGroup converts a Query to a SQL GROUP BY statement.
func ToSqlGroupSlice(query Query, translations SqlTranslations) ([]string, error)
ToSqlGroupSlice converts a Query to a slice of SQL GROUP BY statements.
func ToSqlLimit(query Query) (int, error)
ToSqlLimit converts a Query to a SQL LIMIT statement.
func ToSqlOffset(query Query) (int, error)
ToSqlOffset converts a Query to a SQL OFFSET statement.
func ToSqlOrderBy(query Query, translations SqlTranslations) (string, error)
ToSqlOrderBy converts a Query to a SQL ORDER BY statement.
func ToSqlOrderBySlice(query Query, translations SqlTranslations) ([]string, error)
ToSqlOrderBySlice converts a Query to a slice of SQL ORDER BY statements.
func ToSqlPreload(query Query, preloadable SqlPreloadable) ([]string, error)
ToSqlPreload converts a Query to a SQL preload statement.
func ToSqlSelect(query Query, translations SqlTranslations) (string, error)
ToSqlSelect converts a Query to a SQL SELECT statement.
func ToSqlSelectSlice(query Query, translations SqlTranslations) ([]string, error)
ToSqlSelectSlice converts a Query to a slice of SQL SELECT statements.
func ToSqlWhere(query Query, translations SqlTranslations) (string, []interface{}, error)
ToSqlWhere converts a Query to a SQL WHERE statement.
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 (c Condition) Valid() bool
Valid returns true if the condition is valid.
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(qs string) (Query, error)
FromQueryString returns a Query from a query string.
func FromURLValues(params url.Values) (Query, error)
FromQueryString returns a Query from a query string.
Query is a query to filter on.
type Sort struct {
Field string
Reverse bool
}
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)
}
SqlPreloadable is a map of preloads (key) and their corresponding model (value).
type SqlPreloadable map[string]string
SqlTranslations is a map of field names to SQL translations.
type SqlTranslations map[string]SqlFieldTranslation
Generated by gomarkdoc