Trying out paginated cursortoken variant [UNTESTED]
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 2m11s
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 2m11s
This commit is contained in:
33
cursortoken/tokenPaginate.go
Normal file
33
cursortoken/tokenPaginate.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package cursortoken
|
||||
|
||||
import "strconv"
|
||||
|
||||
type CTPaginated struct {
|
||||
Mode Mode
|
||||
Page int
|
||||
}
|
||||
|
||||
func Page(p int) CursorToken {
|
||||
return CTPaginated{
|
||||
Mode: CTMNormal,
|
||||
Page: p,
|
||||
}
|
||||
}
|
||||
|
||||
func PageEnd() CursorToken {
|
||||
return CTPaginated{
|
||||
Mode: CTMEnd,
|
||||
Page: 0,
|
||||
}
|
||||
}
|
||||
|
||||
func (c CTPaginated) Token() string {
|
||||
if c.Mode == CTMStart {
|
||||
return "$1"
|
||||
}
|
||||
if c.Mode == CTMEnd {
|
||||
return "$end"
|
||||
}
|
||||
|
||||
return "$" + strconv.Itoa(c.Page)
|
||||
}
|
Reference in New Issue
Block a user