Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Paginator for the :many context? #1184

Unanswered
basilex asked this question in Q&A
Discussion options

Hi, All!
Is there a solution to paginate :many context?
Thanx a lot!

You must be logged in to vote

Replies: 1 comment

Comment options

In my reading of the docs, you would do:

-- name: GetThings :many
SELECT * FROM things
 WHERE field = $1
 ORDER BY created_at desc
 LIMIT $2 OFFSET $3;

The generated function looks like this:

type GetThingsParams struct {
	Field string
	Limit int32
	Offset int32
}
type GetThingsRow struct {
	ID int32
	Field string
 ...
}
func (q *Queries) GetThings(ctx context.Context, arg GetThingsParams) ([]GetThingRow, error) {
 ...
}
You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
Converted from issue

This discussion was converted from issue #978 on September 12, 2021 19:46.

AltStyle によって変換されたページ (->オリジナル) /