sqlxx

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2020 License: MIT Imports: 5 Imported by: 4

README

sqlxx GoDoc Go Report Card CircleCI Coverage Status Latest Release

General purpose extensions to golang's github.com/jmoiron/sqlx.

Documentation

Overview

Package sqlxx extends github.com/jmoiron/sqlx.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToSnake

func ToSnake(s string) string

ToSnake maps from CamelCase to snake_case.

Types

type Ctx

type Ctx = context.Context

Ctx is a synonym for convenience.

type DB

type DB struct {
	*sqlx.DB
}

DB is a wrapper around sqlx.DB.

func NewDB

func NewDB(db *sqlx.DB) *DB

NewDB returns a new sqlxx DB wrapper for a pre-existing *sqlx.DB.

func (*DB) BeginTxx

func (db *DB) BeginTxx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)

BeginTxx begins a transaction and returns an *sqlxx.Tx instead of an *sqlx.Tx.

func (*DB) NamedGetContext added in v0.2.0

func (db *DB) NamedGetContext(ctx Ctx, dest interface{}, query string, arg interface{}) error

NamedGetContext within a transaction and context. Any named placeholder parameters are replaced with fields from arg.

func (*DB) NamedIn added in v0.2.0

func (db *DB) NamedIn(queryIn string, arg interface{}) (query string, args []interface{}, err error)

NamedIn expands slice values in arg returning the modified query string and a new arg list that can be executed by a database.

func (*DB) NamedSelectContext added in v0.2.0

func (db *DB) NamedSelectContext(ctx Ctx, dest interface{}, query string, arg interface{}) error

NamedSelectContext within a transaction and context. Any named placeholder parameters are replaced with fields from arg.

type Tx

type Tx struct {
	*sqlx.Tx
}

Tx is an sqlxx wrapper around sqlx.Tx with extra functionality.

func (*Tx) NamedGetContext

func (tx *Tx) NamedGetContext(ctx Ctx, dest interface{}, query string, arg interface{}) error

NamedGetContext within a transaction and context. Any named placeholder parameters are replaced with fields from arg.

func (*Tx) NamedIn

func (tx *Tx) NamedIn(queryIn string, arg interface{}) (query string, args []interface{}, err error)

NamedIn expands slice values in arg returning the modified query string and a new arg list that can be executed by a database.

func (*Tx) NamedSelectContext

func (tx *Tx) NamedSelectContext(ctx Ctx, dest interface{}, query string, arg interface{}) error

NamedSelectContext within a transaction and context. Any named placeholder parameters are replaced with fields from arg.

Jump to

Keyboard shortcuts

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