database

package
v0.0.0-...-faaee1e Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package database provides support for database interaction.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound              = errors.New("not found")
	ErrInvalidID             = errors.New("Invalid ID format")
	ErrAuthenticationFailure = errors.New("authentication failed")
	ErrForbidden             = errors.New("action forbidden")
)

Functions

func Log

func Log(query string, args ...interface{}) string

Log provides a parsed print version of the query and parameters (sqlx does not provide it). PS: This function is traversing linearly to the query string so it is not efficient for the task at hand.

func NamedQuerySlice

func NamedQuerySlice(ctx context.Context, db *sqlx.DB, query string, data interface{}, dest interface{}) error

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

func NamedQueryStruct

func NamedQueryStruct(ctx context.Context, db *sqlx.DB, query string, data interface{}, dest interface{}) 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) (*sqlx.DB, error)

Open function configures and opens a database connection.

func StatusCheck

func StatusCheck(ctx context.Context, db *sqlx.DB) error

StatusCheck returns nil if it can successfully talk to the database engine.

Types

type Config

type Config struct {
	User       string
	Password   string
	Hostname   string
	Name       string
	DisableTLS bool
}

Config is the required props for connecting to database.

Jump to

Keyboard shortcuts

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