Documentation ¶
Index ¶
- Variables
- func AddTxToContext(ctx context.Context, tx *sql.Tx) context.Context
- func ConnectoToTestDB() *sql.DB
- func Test(cb func(ctx context.Context, db *sql.DB))
- func TxFromContext(ctx context.Context) *sql.Tx
- type Base
- func (r *Base) Conn(ctx context.Context) Connection
- func (r *Base) Exec(ctx context.Context, query string, args ...interface{}) (int64, error)
- func (r *Base) Insert(ctx context.Context, tableName string, values map[string]interface{}) error
- func (r *Base) Update(ctx context.Context, tableName string, id string, ...) error
- type Connection
- type TxKeyType
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNoRowsUpdated = errors.New("error on Update, no affected rows")
View Source
var TxKey = TxKeyType("tx")
Functions ¶
func ConnectoToTestDB ¶
func Test ¶
Test connects to the database, starts a transaction and puts it in the context passing it to the given callback. This context is supposed to be used by all the repositories in the test. After the callback is run, the transaction is rolled back returning the database to the initial state.
Types ¶
type Base ¶
type Base struct {
// contains filtered or unexported fields
}
type Connection ¶
Click to show internal directories.
Click to hide internal directories.