query

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 9 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 query parses PostgREST-style list parameters and builds parameterized SQL.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidRequest = errors.New("invalid request")

Functions

This section is empty.

Types

type Filter

type Filter struct {
	Column string
	Op     string
	Values []string
	Negate bool
}

type ListRequest

type ListRequest struct {
	Select  []string
	Filters []Filter
	Order   []Order
	Limit   int
	Offset  int
	// contains filtered or unexported fields
}

func ParseListRequest

func ParseListRequest(rawQuery string) (ListRequest, error)

ParseListRequest takes the raw query string because url.URL.Query drops any pair it cannot parse, and a dropped filter returns rows the client excluded.

func (ListRequest) LimitSet

func (r ListRequest) LimitSet() bool

type Nulls

type Nulls int
const (
	NullsDefault Nulls = iota
	NullsFirst
	NullsLast
)

type Order

type Order struct {
	Column string
	Desc   bool
	Nulls  Nulls
}

type Statement

type Statement struct {
	SQL  string
	Args []any
}

func BuildDelete

func BuildDelete(table *schema.Table, key schema.Column, pk string) Statement

func BuildInsert

func BuildInsert(table *schema.Table, row map[string]any) (Statement, error)

func BuildSelect

func BuildSelect(table *schema.Table, req ListRequest, maxPageSize int) (Statement, error)

func BuildSelectByPK

func BuildSelectByPK(table *schema.Table, key schema.Column, pk string) Statement

func BuildUpdate

func BuildUpdate(table *schema.Table, key schema.Column, pk string, row map[string]any) (Statement, error)

Jump to

Keyboard shortcuts

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