Documentation
¶
Overview ¶
Package db provides support for access to a mysql database using the mysql driver
Index ¶
- Variables
- func ExecContext(ctx context.Context, log *logger.Logger, db sqlx.ExtContext, query string) (sql.Result, error)
- func NamedExecContext(ctx context.Context, log *logger.Logger, db sqlx.ExtContext, query string, ...) (sql.Result, error)
- func NamedQueryStruct(ctx context.Context, log *logger.Logger, db sqlx.ExtContext, query string, ...) error
- func Open(config Config) (*sqlx.DB, error)
- func StatusCheck(ctx context.Context, db *sqlx.DB) error
- type Config
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrDBNotFound = sql.ErrNoRows ErrDBDuplicatedEntry = errors.New("duplicated entry") ErrUndefinedTable = errors.New("undefined table") )
Set of error variables for CRUD operations.
Functions ¶
func ExecContext ¶
func ExecContext(ctx context.Context, log *logger.Logger, db sqlx.ExtContext, query string) (sql.Result, error)
ExecContext is a helper function to execute a CUD operation with logging and tracing.
func NamedExecContext ¶
func NamedExecContext(ctx context.Context, log *logger.Logger, db sqlx.ExtContext, query string, data any) (sql.Result, error)
NamedExecContext is a helper function to execute a CUD operation with logging and tracing where field replacement is necessary.
func NamedQueryStruct ¶
func NamedQueryStruct(ctx context.Context, log *logger.Logger, 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 where field replacement is necessary.
Types ¶
Click to show internal directories.
Click to hide internal directories.