Documentation
¶
Index ¶
- func ExtractQueryParams(queryParams map[string][]string, skip ...string) map[string]interface{}
- func MSSQLPlaceholder(position int) string
- func MySQLPlaceholder(_ int) string
- func OraclePlaceholder(position int) string
- func PostgreSQLPlaceholder(position int) string
- func RemoveOrderLimitOffset(sql string) string
- func SetPlaceholderFormat(format func(int) string)
- type BaseFilter
- type Query
- func (q Query) GetSQL() (string, []interface{})
- func (q Query) GroupBy(fields ...string) Query
- func (q Query) GroupWhere(fn func(Query) Query) Query
- func (q Query) Having(condition string, args ...interface{}) Query
- func (q Query) Join(table string, condition string) Query
- func (q Query) LeftJoin(table string, condition string) Query
- func (q Query) Limit(limit int) Query
- func (q Query) Offset(offset int) Query
- func (q Query) OrGroupWhere(fn func(Query) Query) Query
- func (q Query) OrWhere(condition string, args ...interface{}) Query
- func (q Query) OrWhereEqual(field string, value interface{}) Query
- func (q Query) OrWhereILike(field string, pattern string) Query
- func (q Query) OrWhereIn(field string, values ...interface{}) Query
- func (q Query) OrWhereLike(field string, pattern string) Query
- func (q Query) OrderBy(field string, direction string) Query
- func (q Query) RightJoin(table string, condition string) Query
- func (q Query) Where(condition string, args ...interface{}) Query
- func (q Query) WhereEqual(field string, value interface{}) Query
- func (q Query) WhereILike(field string, pattern string) Query
- func (q Query) WhereIn(field string, values ...interface{}) Query
- func (q Query) WhereLike(field string, pattern string) Query
- func (q Query) WhereNotEqual(field string, value interface{}) Query
- func (q Query) WhereNotIn(field string, values ...interface{}) Query
- func (q Query) WhereNotNull(field string) Query
- func (q Query) WhereNull(field string) Query
- func (q Query) WhereRaw(condition string) Query
- type QueryFilter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractQueryParams ¶
ExtractQueryParams converts URL parameters to a map for filters
func MSSQLPlaceholder ¶
MSSQLPlaceholder returns a placeholder for MS SQL Server (@p1, @p2, ...)
func MySQLPlaceholder ¶
MySQLPlaceholder returns a placeholder for MySQL (?)
func OraclePlaceholder ¶
OraclePlaceholder returns a placeholder for Oracle (:1, :2, ...)
func PostgreSQLPlaceholder ¶
PostgreSQLPlaceholder returns a placeholder for PostgreSQL ($n)
func RemoveOrderLimitOffset ¶
RemoveOrderLimitOffset removes ORDER BY, LIMIT, OFFSET from an SQL query Useful for counting total records
func SetPlaceholderFormat ¶
SetPlaceholderFormat sets the placeholder format For example, for MySQL: ? For PostgreSQL: $1, $2, ...
Types ¶
type BaseFilter ¶
type BaseFilter struct{}
BaseFilter is the base implementation of a filter
func (*BaseFilter) Apply ¶
func (f *BaseFilter) Apply(query Query, inputs map[string]interface{}, withDefault bool) Query
Apply applies filters to the query
func (*BaseFilter) Default ¶
func (f *BaseFilter) Default(query Query) Query
Default applies default filters This method must be overridden in specific filter implementations
type Query ¶
type Query struct {
SQL string
Args []interface{}
}
Query represents an SQL query with arguments
func ApplyFilters ¶
func ApplyFilters(sql string, filterInstance QueryFilter, inputs map[string]interface{}, withDefault bool) Query
ApplyFilters applies filters to the SQL query sql - the base SQL query filterInstance - an instance of a filter implementing the QueryFilter interface inputs - a map of input parameters where keys correspond to filter method names withDefault - a flag for applying default filters
func BuildCountQuery ¶
BuildCountQuery creates a query for counting total rows
func (Query) GroupWhere ¶
GroupWhere adds a group of conditions with AND
func (Query) OrGroupWhere ¶
OrGroupWhere adds a group of conditions with OR
func (Query) OrWhereEqual ¶
OrWhereEqual adds an OR field = value condition
func (Query) OrWhereILike ¶
OrWhereILike adds an OR ILIKE (case-insensitive) condition
func (Query) OrWhereLike ¶
OrWhereLike adds an OR LIKE condition
func (Query) WhereEqual ¶
WhereEqual adds an equality condition
func (Query) WhereILike ¶
WhereILike adds an ILIKE (case-insensitive) condition
func (Query) WhereNotEqual ¶
WhereNotEqual adds an inequality condition
func (Query) WhereNotIn ¶
WhereNotIn adds a NOT IN condition
func (Query) WhereNotNull ¶
WhereNotNull adds an IS NOT NULL condition