Add support for offset in table rows endpoint, dry up code
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user