db

package
v1.21.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteQuery added in v1.18.0

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

func Keeps added in v1.21.0

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 added in v1.20.0

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 added in v1.20.0

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 added in v1.18.0

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

type Option added in v1.18.0

type Option func(*Callback)

func WithAfter added in v1.18.0

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

func WithBefore added in v1.18.0

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

func WithGuard added in v1.20.0

func WithGuard(guard actionrpc.Guard) Option

WithGuard runs the query under the guard of the run.

type Req added in v1.18.0

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 added in v1.18.0

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

func (*Req) Execute added in v1.18.0

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

type Res added in v1.18.0

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

type Result added in v1.18.0

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