dal

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2025 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("record not found")

Functions

func Create

func Create(ctx context.Context, database *sql.DB, q string, args ...any) (int64, error)

func FindColumns

func FindColumns[T Column](ctx context.Context, database *sql.DB, q string, args ...any) ([]T, error)

func FindRows

func FindRows[T any, PT Row[T]](ctx context.Context, database *sql.DB, q string, args ...any) ([]T, error)

func GetColumn

func GetColumn[T Column](ctx context.Context, database *sql.DB, q string, args ...any) (T, error)

func GetRow

func GetRow[T any, PT Row[T]](ctx context.Context, database *sql.DB, q string, args ...any) (T, error)

func InArgs

func InArgs[T Column](tt []T) (string, []any)

Types

type Column

type Column interface {
	~byte | ~int16 | ~int32 | ~int64 | ~float64 |
		~string | ~bool | uuid.UUID | time.Time
}

type DAL

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

func New

func New(dbString string) *DAL

func Open

func Open(dbFile string, devMode bool) (*DAL, error)

func (*DAL) Close

func (dal *DAL) Close()

func (*DAL) DB

func (dal *DAL) DB() *sql.DB

func (*DAL) Init

func (dal *DAL) Init() error

type Row

type Row[T any] interface {
	PtrFields() []any
	*T
}

Jump to

Keyboard shortcuts

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