Add support for offset in table rows endpoint, dry up code

This commit is contained in:
Dan Sosedoff
2016-01-07 21:18:22 -06:00
parent 9b5764d4fb
commit 61523e33df
3 changed files with 36 additions and 17 deletions

View File

@@ -21,6 +21,7 @@ type Client struct {
// Struct to hold table rows browsing options
type RowsOptions struct {
Offset int // Number of rows to skip
Limit int // Number of rows to fetch
SortColumn string // Column to sort by
SortOrder string // Sort direction (ASC, DESC)
@@ -110,6 +111,10 @@ func (client *Client) TableRows(table string, opts RowsOptions) (*Result, error)
sql += fmt.Sprintf(" LIMIT %d", opts.Limit)
}
if opts.Offset > 0 {
sql += fmt.Sprintf(" OFFSET %d", opts.Offset)
}
return client.query(sql)
}