Help us shape the future of Go! Take the 2026 Go Developer Survey

db

package
v1.28.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteQuery

func ExecuteQuery(data map[string]any, opts ...Option) (map[string]any, error)

func Keeps

func Keeps() []string

Keeps returns the kinds of guard the db action keeps to: it runs only a statement that reads under read-only, and connects only to a host the guard allows.

func Params

func Params() []string

Params returns the keys the db action takes in with.

func Serve

func Serve()

Types

type Action

type Action struct {
	// contains filtered or unexported fields
}

func (*Action) Run

func (a *Action) Run(with map[string]any) (map[string]any, error)

func (*Action) RunStep

func (a *Action) RunStep(call actionrpc.Call) (map[string]any, map[string]any, error)

RunStep runs the query under the guard of the run, which may allow only reading, or only some hosts.

type Callback

type Callback struct {
	// contains filtered or unexported fields
}

type Option

type Option func(*Callback)

func WithAfter

func WithAfter(f func(result *Result)) Option

func WithBefore

func WithBefore(f func(query string, params []any)) Option

func WithGuard

func WithGuard(guard actionrpc.Guard) Option

WithGuard runs the query under the guard of the run.

type Req

type Req struct {
	Driver  string `map:"driver"`
	DSN     string `map:"dsn"`
	Query   string `map:"query"`
	Params  []any  `map:"params"`
	Timeout string `map:"timeout"`
	// contains filtered or unexported fields
}

func ParseRequest

func ParseRequest(with map[string]any) (*Req, string, time.Duration, error)

func (*Req) Execute

func (r *Req) Execute(driverDSN string, timeout time.Duration) (res map[string]any, err error)

type Res

type Res struct {
	Code         int    `map:"code"`
	RowsAffected int64  `map:"rows_affected"`
	Rows         []any  `map:"rows"`
	Error        string `map:"error"`
}

type Result

type Result struct {
	Req    Req           `map:"req"`
	Res    Res           `map:"res"`
	RT     time.Duration `map:"rt"`
	Status int           `map:"status"`
}

Jump to

Keyboard shortcuts

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