Versions in this module Expand all Collapse all v1 v1.0.0 Sep 27, 2023 Changes in this version + const SortAscending + const SortDescending + var ErrInvalidType = errors.New("invalid type") + var ErrNoForeignKeyMatch = errors.New("no foreign key matched") + var ErrNoForeignKeys = errors.New("no foreign keys were found") + var ErrNoIdentity = errors.New("identity not found") + var ErrNotFound = fmt.Errorf("not found: %w", pgx.ErrNoRows) + func All(db DB, v *[]T) error + func ClearCache() + func CollectRows(rows pgx.Rows) (items []T, err error) + func CollectStrings(rows pgx.Rows) ([]string, error) + func Exec(db DB, sql string, args ...any) error + func First(db DB, v any) error + func Insert(db DB, v any) error + func Many(db DB, v *[]T, sql string, args ...any) error + func One(db DB, v any, sql string, args ...any) error + func RunScript(conn DB, script string, tdata any) error + func SetScriptFS(dir fs.FS) + func Update(db DB, v any) error + type Columns []string + func (c Columns) AssignmentList(start int) string + func (c Columns) List() string + func (c Columns) PrefixedList(prefix string) string + func (c Columns) ValueList(start int) string + type DB interface + Begin func(ctx context.Context) (pgx.Tx, error) + Exec func(ctx context.Context, sql string, args ...any) (pgconn.CommandTag, error) + Query func(ctx context.Context, sql string, args ...any) (pgx.Rows, error) + QueryRow func(ctx context.Context, sql string, args ...any) pgx.Row + type FK struct + Column string + Table string + type Field struct + Column string + FK *FK + Identity bool + Index int + Name string + ReadOnly bool + Schema *Schema + func (f *Field) HasSchema() bool + func (f *Field) IsWriteable() bool + type Fields []Field + func (fields Fields) Columns() (columns Columns) + func (fields Fields) ForeignKeys() Fields + func (fields Fields) Identity() (*Field, []int, error) + func (fields Fields) Writeable() Fields + type ID int64 + func CollectIDs(rows pgx.Rows) ([]ID, error) + func ParseID(str string) (ID, error) + func (id ID) String() string + type PaginationOptions struct + Page int + PageSize int + Query string + QueryColumns []string + Record Record + SortBy string + SortDirection SortDirection + type PaginationResults struct + End int + HasNext bool + Items []T + Page int + Start int + Total int64 + func Paginate(db DB, opts *PaginationOptions) (*PaginationResults[T], error) + type Record interface + TableName func() string + type Schema struct + Fields Fields + Parent *Schema + Table string + Type reflect.Type + func Analyze(v interface{}) (sch *Schema, err error) + func MustAnalyze(v interface{}) *Schema + func (s *Schema) IsRoot() bool + type SortDirection = string