Documentation ¶
Overview ¶
Package db2 is the replacement for db. It provides low level db connection and query capabilities.
Index ¶
- Constants
- Variables
- type PageQuery
- func (p PageQuery) ApplyTo(sql sq.SelectBuilder, col string) (sq.SelectBuilder, error)
- func (p PageQuery) ApplyToUsingCursor(sql sq.SelectBuilder, col string, cursor interface{}) (sq.SelectBuilder, error)
- func (p PageQuery) CursorInt64() (int64, error)
- func (p PageQuery) CursorInt64Pair(sep string) (l int64, r int64, err error)
- func (p PageQuery) GetContinuations(records interface{}) (next PageQuery, prev PageQuery, err error)
- func (p PageQuery) Invert() PageQuery
- type Pageable
Constants ¶
const ( // DefaultPageSize is the default page size for db queries DefaultPageSize = 10 // MaxPageSize is the max page size for db queries MaxPageSize = 200 // OrderAscending is used to indicate an ascending order in request params OrderAscending = "asc" // OrderDescending is used to indicate an descending order in request params OrderDescending = "desc" // DefaultPairSep is the default separator used to separate two numbers for CursorInt64Pair DefaultPairSep = "-" )
Variables ¶
var ( // ErrInvalidOrder is an error that occurs when a user-provided order string // is invalid ErrInvalidOrder = errors.New("Invalid order") // ErrInvalidLimit is an error that occurs when a user-provided limit num // is invalid ErrInvalidLimit = errors.New("Invalid limit") // ErrInvalidCursor is an error that occurs when a user-provided cursor string // is invalid ErrInvalidCursor = errors.New("Invalid cursor") // ErrNotPageable is an error that occurs when the records provided to // PageQuery.GetContinuations cannot be cast to Pageable ErrNotPageable = errors.New("Records provided are not Pageable") )
Functions ¶
This section is empty.
Types ¶
type PageQuery ¶
PageQuery represents a portion of a Query struct concerned with paging through a large dataset.
func MustPageQuery ¶
MustPageQuery behaves as NewPageQuery, but panics upon error
func NewPageQuery ¶
NewPageQuery creates a new PageQuery struct, ensuring the order, limit, and cursor are set to the appropriate defaults and are valid.
func (PageQuery) ApplyTo ¶
func (p PageQuery) ApplyTo( sql sq.SelectBuilder, col string, ) (sq.SelectBuilder, error)
ApplyTo returns a new SelectBuilder after applying the paging effects of `p` to `sql`. This method provides the default case for paging: int64 cursor-based paging by an id column.
func (PageQuery) ApplyToUsingCursor ¶
func (p PageQuery) ApplyToUsingCursor( sql sq.SelectBuilder, col string, cursor interface{}, ) (sq.SelectBuilder, error)
ApplyToUsingCursor returns a new SelectBuilder after applying the paging effects of `p` to `sql`. This method allows any type of cursor by a single column
func (PageQuery) CursorInt64 ¶
CursorInt64 parses this query's Cursor string as an int64
func (PageQuery) CursorInt64Pair ¶
CursorInt64Pair parses this query's Cursor string as two int64s, separated by the provided separator
Directories ¶
Path | Synopsis |
---|---|
Package core contains database record definitions useable for reading rows from a Stellar Core db
|
Package core contains database record definitions useable for reading rows from a Stellar Core db |
Package history contains database record definitions useable for reading rows from a the history portion of horizon's database
|
Package history contains database record definitions useable for reading rows from a the history portion of horizon's database |
Package sqx contains utilities and extensions for the squirrel package which is used by horizon to generate sql statements.
|
Package sqx contains utilities and extensions for the squirrel package which is used by horizon to generate sql statements. |