Documentation ¶
Index ¶
- Variables
- func NamedCountQuery(ctx context.Context, db *sqlx.DB, query string, data interface{}) (int, error)
- func NamedExecQuery(ctx context.Context, db *sqlx.DB, query string, data interface{}) error
- func NamedSliceQuery(ctx context.Context, db *sqlx.DB, query string, data interface{}, ...) error
- func NamedStructQuery(ctx context.Context, db *sqlx.DB, query string, data interface{}, ...) error
- func Open(config Config) (*sqlx.DB, error)
- func Status(ctx context.Context, db *sqlx.DB) error
- type Config
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNotFound = errors.New("not found") ErrInvalidID = errors.New("ID is not in its proper form") ErrAuthenticationFailure = errors.New("authentication failed") ErrForbidden = errors.New("attempted action is not allowed") )
Set of error variables for CRUD operations.
Functions ¶
func NamedCountQuery ¶
NamedCountQuery is a helper function for executing queries that return a count.
@param ctx - context @param db - database connection @param query - query to execute @param data - data to bind to the query @return int - integer value returned from the query @return error - error if any
func NamedExecQuery ¶
NamedExecQuery - helper function for executing queries that return no rows. Most of the time, this will be used for INSERT, UPDATE, and DELETE queries.
@param ctx - context @param db - database connection @param query - query to execute @param data - data to bind to the query @return error - error if any
func NamedSliceQuery ¶
func NamedSliceQuery(ctx context.Context, db *sqlx.DB, query string, data interface{}, dest interface{}) error
NamedSliceQuery - helper function for executing queries that return a slice of rows. Most of the time, this will be used for SELECT queries.
@param ctx - context @param db - database connection @param query - query to execute @param data - data to bind to the query @param dest - destination to scan the rows into @return error - error if any
func NamedStructQuery ¶
func NamedStructQuery(ctx context.Context, db *sqlx.DB, query string, data interface{}, dest interface{}) error
NamedStructQuery - helper function for executing queries that return a single row. Most of the time, this will be used for SELECT queries.
@param ctx - context @param db - database connection @param query - query to execute @param data - data to bind to the query @param dest - destination to scan the row into @return error - error if any
Types ¶
Click to show internal directories.
Click to hide internal directories.