dbutil

package module
v0.0.0-...-86f0416 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

README

db

db utils

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotTx = errors.New("not a Tx")
View Source
var ZeroEffected = errors.New("0 row effected")

Functions

func Insert

func Insert(db *sql.DB, q string, v ...interface{}) (int64, error)

func Query

func Query(db *sql.DB, obj interface{}, q string, v ...interface{}) error

func ToSnake

func ToSnake(in string) string

func Update

func Update(db *sql.DB, q string, v ...interface{}) (effected int64, err error)

Types

type JsonNumList

type JsonNumList []int64

func (*JsonNumList) Scan

func (list *JsonNumList) Scan(value interface{}) error

func (JsonNumList) Value

func (list JsonNumList) Value() (driver.Value, error)

type JsonStrList

type JsonStrList []string

func (*JsonStrList) Scan

func (list *JsonStrList) Scan(value interface{}) error

func (JsonStrList) Value

func (list JsonStrList) Value() (driver.Value, error)

type MayTx

type MayTx struct {
	Tx *sql.Tx
	DB *sql.DB
}

func NewMayTx

func NewMayTx(db *sql.DB, tx *sql.Tx) *MayTx

func (*MayTx) Commit

func (tx *MayTx) Commit() error

func (*MayTx) Exec

func (tx *MayTx) Exec(query string, args ...interface{}) (sql.Result, error)

func (*MayTx) Insert

func (tx *MayTx) Insert(q string, v ...interface{}) (int64, error)

func (*MayTx) Prepare

func (tx *MayTx) Prepare(query string) (*sql.Stmt, error)

func (*MayTx) Query

func (tx *MayTx) Query(query string, args ...interface{}) (*sql.Rows, error)

func (*MayTx) QueryRow

func (tx *MayTx) QueryRow(query string, args ...interface{}) *sql.Row

func (*MayTx) Rollback

func (tx *MayTx) Rollback() error

func (*MayTx) Stmt

func (tx *MayTx) Stmt(stmt *sql.Stmt) *sql.Stmt

func (*MayTx) Update

func (tx *MayTx) Update(q string, v ...interface{}) (effected int64, err error)

type NameList

type NameList []string

func (*NameList) Scan

func (sl *NameList) Scan(value interface{}) error

func (NameList) Value

func (sl NameList) Value() (driver.Value, error)

type NullFloat64

type NullFloat64 struct {
	Float64 float64
	Valid   bool
}

func (NullFloat64) MarshalJSON

func (n NullFloat64) MarshalJSON() ([]byte, error)

func (*NullFloat64) Scan

func (n *NullFloat64) Scan(value interface{}) error

func (*NullFloat64) UnmarshalJSON

func (n *NullFloat64) UnmarshalJSON(data []byte) error

func (NullFloat64) Value

func (n NullFloat64) Value() (driver.Value, error)

type NullInt64

type NullInt64 struct {
	Int64 int64
	Valid bool
}

func (NullInt64) MarshalJSON

func (n NullInt64) MarshalJSON() ([]byte, error)

func (*NullInt64) Scan

func (n *NullInt64) Scan(value interface{}) error

func (*NullInt64) UnmarshalJSON

func (n *NullInt64) UnmarshalJSON(data []byte) error

func (NullInt64) Value

func (n NullInt64) Value() (driver.Value, error)

type NullString

type NullString struct {
	String string
	Valid  bool
}

func (NullString) MarshalJSON

func (ns NullString) MarshalJSON() ([]byte, error)

func (*NullString) Scan

func (ns *NullString) Scan(value interface{}) error

func (*NullString) UnmarshalJSON

func (ns *NullString) UnmarshalJSON(data []byte) error

func (NullString) Value

func (ns NullString) Value() (driver.Value, error)

type NullTime

type NullTime struct {
	Time  time.Time
	Valid bool
}

func (NullTime) MarshalJSON

func (nt NullTime) MarshalJSON() ([]byte, error)

func (*NullTime) Scan

func (nt *NullTime) Scan(value interface{}) (err error)

func (*NullTime) UnmarshalJSON

func (nt *NullTime) UnmarshalJSON(data []byte) error

func (NullTime) Value

func (nt NullTime) Value() (driver.Value, error)

type NullUint64

type NullUint64 struct {
	Uint64 uint64
	Valid  bool
}

func (NullUint64) MarshalJSON

func (n NullUint64) MarshalJSON() ([]byte, error)

func (*NullUint64) Scan

func (n *NullUint64) Scan(value interface{}) error

func (*NullUint64) UnmarshalJSON

func (n *NullUint64) UnmarshalJSON(data []byte) error

func (NullUint64) Value

func (n NullUint64) Value() (driver.Value, error)

type NumList

type NumList []int64

func (*NumList) Scan

func (sl *NumList) Scan(value interface{}) error

func (NumList) Value

func (sl NumList) Value() (driver.Value, error)

type PreparedScan

type PreparedScan struct {
	// contains filtered or unexported fields
}

func (*PreparedScan) GetScanFields

func (p *PreparedScan) GetScanFields(v interface{}) (fields []interface{}, err error)

type TableMeta

type TableMeta struct {
	Type reflect.Type
	// contains filtered or unexported fields
}

func GetTableMeta

func GetTableMeta(typ reflect.Type) *TableMeta

func (*TableMeta) GetScanFields

func (m *TableMeta) GetScanFields(names []string, v interface{}) (fields []interface{}, err error)

func (*TableMeta) PrepareScan

func (m *TableMeta) PrepareScan(names []string) (*PreparedScan, error)

Directories

Path Synopsis
dialects

Jump to

Keyboard shortcuts

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