sqlbpager

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package sqlbpager applies a sqlkit.Pager to a go-sqlbuilder SelectBuilder.

It lives in a subpackage so that the root sqlkit package does not depend on go-sqlbuilder.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(sb *sqlbuilder.SelectBuilder, p *sqlkit.Pager)

Apply adds the keyset condition, ORDER BY, LIMIT (size+1) and OFFSET of p to sb.

Note: sb.OrderBy of go-sqlbuilder APPENDS columns, while sb.Asc()/sb.Desc() set the direction of the whole list; do not call them together with Apply. Check p.Err() before executing the query.

Example
package main

import (
	"fmt"

	"github.com/huandu/go-sqlbuilder"

	"github.com/boostgo/sqlkit"
	"github.com/boostgo/sqlkit/sqlbpager"
)

func main() {
	p := sqlkit.OffsetPager(sqlkit.PageRequest{Page: 2, Size: 10}, sqlkit.Asc("id"))

	sb := sqlbuilder.NewSelectBuilder()
	sb.Select("id").From("users")
	sb.Where(sb.Equal("tenant", "acme"))
	sqlbpager.Apply(sb, p)

	query, args := sb.BuildWithFlavor(sqlbuilder.PostgreSQL)
	fmt.Println(query)
	fmt.Println(args)
}
Output:
SELECT id FROM users WHERE tenant = $1 ORDER BY id ASC LIMIT $2 OFFSET $3
[acme 11 10]

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL