secuela

package module
v0.0.0-...-e066555 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: MPL-2.0 Imports: 8 Imported by: 0

README

secuela

builds.sr.ht status

Scan values from a database into Go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArgMap

func ArgMap(tag string, sct any) map[string]any

Types

type Client

type Client struct {
	// Tag is the struct tag to map the column name to.
	Tag string

	// ColumnTagMap takes a database column name and returns what struct tag
	// value it should match against.
	ColumnTagMap func(col string) string

	// OnQueryExec is a function that runs before every Query or Exec call is
	// made to the underlying DB object. Useful for logging.
	OnQueryExec func(stmt string, args []any)

	// StmtArgsErrors indicates whether errors should be wrapped with the
	// statement and args that caused the error.
	StmtArgsErrors bool

	// DB is the underlying connection to the database.
	DB *sql.DB
}

func (*Client) Begin

func (c *Client) Begin() (*Transaction, error)

func (*Client) Clone

func (c *Client) Clone() *Client

func (*Client) Exec

func (c *Client) Exec(chk, stmt string, args map[string]any) error

func (*Client) Query

func (c *Client) Query(dst any, stmt string, args map[string]any) error

func (*Client) QueryStream

func (c *Client) QueryStream(stmt string, args map[string]any) (*RowStream, error)

type RowStream

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

func (*RowStream) Close

func (s *RowStream) Close() error

func (*RowStream) Next

func (s *RowStream) Next() bool

func (*RowStream) Scan

func (s *RowStream) Scan(dst any) error

type StmtArgsError

type StmtArgsError struct {
	Stmt string
	Args []any
	Err  error
}

func (*StmtArgsError) Error

func (e *StmtArgsError) Error() string

func (*StmtArgsError) Unwrap

func (e *StmtArgsError) Unwrap() error

type Transaction

type Transaction struct {
	RollbackErrTxDone bool
	// contains filtered or unexported fields
}

func (*Transaction) Commit

func (t *Transaction) Commit() error

func (*Transaction) Exec

func (t *Transaction) Exec(chk, stmt string, args map[string]any) error

func (*Transaction) Query

func (t *Transaction) Query(dst any, stmt string, args map[string]any) error

func (*Transaction) QueryStream

func (t *Transaction) QueryStream(stmt string, args map[string]any) (*RowStream, error)

func (*Transaction) Rollback

func (t *Transaction) Rollback() error

Jump to

Keyboard shortcuts

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