dbc

package
v0.0.0-...-ffb043f Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package dbc is (Database Connection) is used for create to represents low level database interfaces in order to have an unified way to access database handler

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DatabaseConnection

func DatabaseConnection() *sql.DB

func RedisConnection

func RedisConnection() *redis.Client

Types

type RDbc

type RDbc interface {
	Get(ctx context.Context, key string) *redis.StringCmd
	Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.StatusCmd
	Del(ctx context.Context, key ...string) *redis.IntCmd
	GetDel(ctx context.Context, key string) *redis.StringCmd
}

type SqlDbc

type SqlDbc interface {
	Exec(query string, args ...interface{}) (sql.Result, error)
	Prepare(query string) (*sql.Stmt, error)
	Query(query string, args ...interface{}) (*sql.Rows, error)
	QueryRow(query string, args ...interface{}) *sql.Row
	// If you want support transactional
	Transactioner
}

SqlDbc (SQL Database Connection) is a wrapper for SQL Database handler (can be *sql.DB or *sql.Tx)

type Transactioner

type Transactioner interface {
	// Rollback a transaction
	Rollback() error
	// Commit a transaction
	Commit() error
	// TxEnd commits a transaction if no errors, otherwise callback
	// txFunc is the operations wrapped in a transaction
	TxEnd(txFunc func() error) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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