sql

package
v0.0.0-...-8341997 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2017 License: MIT Imports: 1 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseSearch

type BaseSearch struct{}

BaseSearch implements Where, Order and Limit, generically for searches

func (*BaseSearch) Limit

func (*BaseSearch) Limit(q string) string

Limit returns q + "LIMIT ?,?" for paging

func (*BaseSearch) Order

func (b *BaseSearch) Order(q string, sort ...*SortTerm) string

Order returns q + "ORDER BY" the sort key and and order based on the int value

of sort.order.

func (*BaseSearch) Where

func (*BaseSearch) Where(q string, sort ...*SortTerm) string

Where adds WHERE term=value OR ... to the q string for each sort term

in the sort slice. If SortTerm.like = true, it will use a `like` clause
instead of `=`
type Search interface {
	ToQuery() string
	Where(string, ...*SortTerm) string
	Order(string, ...*SortTerm) string
	Limit(string) string
}

Search defines an interface for structs that can be used in sql queries

type SortTerm

type SortTerm struct {
	// contains filtered or unexported fields
}

SortTerm is used to define search terms as well as the ordering for

queries using that search

func NewSortTerm

func NewSortTerm(key, value string, order int, like bool) *SortTerm

NewSortTerm returns a configured SortTerm where any order value other than 0 or 1 will not be used in any queries

Jump to

Keyboard shortcuts

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