data

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyAll

func ApplyAll[T any, S ~[]T](q *psql.ViewQuery[T, S], params *QueryParams) *psql.ViewQuery[T, S]

func ApplyFilter

func ApplyFilter[T any, S ~[]T](q *psql.ViewQuery[T, S], f *Filter) *psql.ViewQuery[T, S]

ApplyFilter applies multiple filter conditions to a query. If no conditions are provided, it does not apply any filters.

func Code

func Code(name string) string

func Order

func Order[T any, S ~[]T](q *psql.ViewQuery[T, S], s *Sort) *psql.ViewQuery[T, S]

func Page

func Page[T any, S ~[]T](q *psql.ViewQuery[T, S], pg *Pagination) *psql.ViewQuery[T, S]

func Slugify

func Slugify(s string) string

Types

type Filter

type Filter struct {
	Conditions []FilterCondition
}

type FilterCondition

type FilterCondition struct {
	Column string
	Mode   MatchMode
	Value  string
}

func (FilterCondition) String

func (c FilterCondition) String() string

type MatchMode

type MatchMode int
const (
	Exact           MatchMode = iota // Exact = 0
	CaseInsensitive                  // CaseInsensitive = 1
	Anywhere                         // Anywhere = 2
	Start                            // Start = 3
	End                              // End = 4
)

func (MatchMode) String

func (m MatchMode) String() string

type Pagination

type Pagination struct {
	Limit  any // number or "ALL"
	Offset int64
}

type QueryParams

type QueryParams struct {
	Pagination
	Filter
	Sort
}

func (QueryParams) String

func (qp QueryParams) String() string

type SliceResult

type SliceResult[T any] struct {
	Data  []T   `json:"data"`
	Total int64 `json:"total"`
}

func Slice

func Slice[T any](data []T, count int64) SliceResult[T]

type Sort

type Sort struct {
	Column    string
	Direction string
}

Jump to

Keyboard shortcuts

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