w2db

package
v0.2.44 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetForm

func GetForm[T any](db QueryDB, req w2.GetFormRequest, opts GetFormOptions[T]) (w2.GetFormResponse[T], error)

func GetFormContext

func GetFormContext[T any](ctx context.Context, db QueryDB, req w2.GetFormRequest, opts GetFormOptions[T]) (w2.GetFormResponse[T], error)

func GetGrid

func GetGrid[T any](db QueryDB, req w2.GetGridRequest, opts GetGridOptions[T]) (w2.GetGridResponse[T], error)

func GetGridContext

func GetGridContext[T any](ctx context.Context, db QueryDB, req w2.GetGridRequest, opts GetGridOptions[T]) (w2.GetGridResponse[T], error)

func InsertForm

func InsertForm[T any](db ExecDB, req w2.SaveFormRequest[T], opts InsertFormOptions) (int, error)

func InsertFormContext

func InsertFormContext[T any](ctx context.Context, db ExecDB, req w2.SaveFormRequest[T], opts InsertFormOptions) (int, error)

func RemoveGrid

func RemoveGrid(db ExecDB, req w2.RemoveGridRequest, opts RemoveGridOptions) (int, error)

func RemoveGridContext

func RemoveGridContext(ctx context.Context, db ExecDB, req w2.RemoveGridRequest, opts RemoveGridOptions) (int, error)

func ReorderGrid

func ReorderGrid(db QueryExecDB, req w2.ReorderGridRequest, opts ReorderGridOptions) (int, error)

func ReorderGridContext

func ReorderGridContext(ctx context.Context, db QueryExecDB, req w2.ReorderGridRequest, opts ReorderGridOptions) (int, error)

func SaveGrid

func SaveGrid[T any](db ExecDB, req w2.SaveGridRequest[T], opts SaveGridOptions[T]) (int, error)

func SaveGridContext

func SaveGridContext[T any](ctx context.Context, db ExecDB, req w2.SaveGridRequest[T], opts SaveGridOptions[T]) (int, error)

func SetLogger added in v0.2.44

func SetLogger(logger *slog.Logger)

func SetSlowThreshold added in v0.2.44

func SetSlowThreshold(threshold time.Duration)

func UpdateForm

func UpdateForm[T any](db ExecDB, req w2.SaveFormRequest[T], opts UpdateFormOptions) (int, error)

func UpdateFormContext

func UpdateFormContext[T any](ctx context.Context, db ExecDB, req w2.SaveFormRequest[T], opts UpdateFormOptions) (int, error)

func WithinTransaction

func WithinTransaction(db *sql.DB, fn func(tx *sql.Tx) error) error

func WithinTransactionContext

func WithinTransactionContext(ctx context.Context, db *sql.DB, fn func(ctx context.Context, tx *sql.Tx) error) error

Types

type ExecDB

type ExecDB interface {
	ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
}

type GetDropdownOptions

type GetDropdownOptions struct {
	From         string
	IDField      string
	TextField    string
	OrderByField string
	BuildSelect  func(sb *sqlbuilder.SelectBuilder)
	Flavor       sqlbuilder.Flavor
	Logger       *slog.Logger
}

type GetFormOptions

type GetFormOptions[T any] struct {
	From        string
	IDField     string
	Select      []string
	Flavor      sqlbuilder.Flavor
	BuildSelect func(sb *sqlbuilder.SelectBuilder)
	Scan        func(row *sql.Row) (T, error)
	Logger      *slog.Logger
}

type GetGridOptions

type GetGridOptions[T any] struct {
	From           string
	Select         []string
	CountExpr      string
	WhereMapping   map[string]string
	OrderByMapping map[string]string
	Flavor         sqlbuilder.Flavor
	BuildBase      func(sb *sqlbuilder.SelectBuilder)
	BuildSelect    func(sb *sqlbuilder.SelectBuilder)
	Scan           func(rows *sql.Rows) (T, error)
	Logger         *slog.Logger
}

type InsertFormOptions

type InsertFormOptions struct {
	Into   string
	Cols   []string
	Values []any
	Flavor sqlbuilder.Flavor
	Logger *slog.Logger
}

type QueryDB

type QueryDB interface {
	QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
	QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
}

type QueryExecDB

type QueryExecDB interface {
	QueryDB
	ExecDB
}

type RemoveGridOptions

type RemoveGridOptions struct {
	From    string
	IDField string
	Flavor  sqlbuilder.Flavor
	Logger  *slog.Logger
}

type ReorderGridOptions

type ReorderGridOptions struct {
	Update      string
	IDField     string
	SetField    string
	Flavor      sqlbuilder.Flavor
	BuildSelect func(sb *sqlbuilder.SelectBuilder)
	Logger      *slog.Logger
}

type SaveGridOptions

type SaveGridOptions[T any] struct {
	Flavor      sqlbuilder.Flavor
	BuildUpdate func(change T) *sqlbuilder.UpdateBuilder
	Logger      *slog.Logger
}

type UpdateFormOptions

type UpdateFormOptions struct {
	Update  string
	IDField string
	Cols    []string
	Values  []any
	Flavor  sqlbuilder.Flavor
	Logger  *slog.Logger
}

Jump to

Keyboard shortcuts

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