Skip to content

[feature request] adding integrated pagination support in select query #3865

Open
@mcarbonneaux

Description

@mcarbonneaux

What do you want to change?

wil be very useful to add pagination on select query.
this avoid the need to be implemented with args.

with defined request like in example:

-- name: ListAuthors :many
SELECT * FROM authors
ORDER BY name;

To be abel to use like this:

	// list all authors pagintated with page size of 10
        // behind the scene use count from select and divide by the size
        // and at each page use limit and offset to get the selected page
	pagedAuthors, err := queries.ListPaginatedAuthors(ctx,10)
	if err != nil {
		return err
	}
        // to loop pages
        pageMax := pagedAuthors.GetMaxPages()
        pagedAuthors.Reset()
        for pagenumber := 0; pagenumber  < pageMax; pagenumber ++ {
            authors := pagedAuthors.Next()
            log.Println(pagenumber)
     	    log.Println(authors)
        }
        // or the get specific page (the 2s page)
        authors := pagedAuthors.Get(2)
        log.Println(authors)

What database engines need to be changed?

any supported

What programming language backends need to be changed?

any language supported (my sample is in go)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions