database

package
v0.0.0-...-53bd342 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2023 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDBNotFound        = errors.New("not found")
	ErrDBDuplicatedEntry = errors.New("duplicated entry")
)

Set of error variables for CRUD operations.

Functions

func Migrate

func Migrate(db *sqlx.DB) error

func NamedExecContext

func NamedExecContext(ctx context.Context, db sqlx.ExtContext, query string, data any) error

NamedExecContext is a helper function to execute a CUD operation.

func NamedQuerySlice

func NamedQuerySlice[T any](ctx context.Context, db sqlx.ExtContext, query string, data any, dest *[]T) error

NamedQuerySlice is a helper function for executing queries that return a collection of data to be unmarshalled into a slice.

func NamedQueryStruct

func NamedQueryStruct(ctx context.Context, db sqlx.ExtContext, query string, data any, dest any) error

NamedQueryStruct is a helper function for executing queries that return a single value to be unmarshalled into a struct type.

func Open

func Open(cfg config.DB) (*sqlx.DB, error)

Open knows how to open a database connection based on the configuration.

func Seed

func Seed(db *sqlx.DB, seed string) error

func Transaction

func Transaction(db *sqlx.DB, f func(db sqlx.ExtContext) error) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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