spcdb

package module
v0.0.0-...-9e6e87f Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2015 License: MIT Imports: 10 Imported by: 0

README

spcdb

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AttributeName = "mapstructure"
	TimeFormat    = "2006-01-02 15:04:05"
)
View Source
var (
	MaxConnsInPool    int           = 20
	TimeoutPing       time.Duration = 2 // in minutes
	DefaultDriverName string        = "postgres"
)

Functions

func NewPoolConnection

func NewPoolConnection(connectionName string, cfg DBConfiguer)

func ReturnToPool

func ReturnToPool(db *DB) bool

Types

type DB

type DB struct {
	*sql.DB
}

func GetFromPool

func GetFromPool(connectionName string) (*DB, error)

func Open

func Open(driverName, dataSourceName string) (*DB, error)

func (*DB) ConnectionName

func (db *DB) ConnectionName() string

func (*DB) ExistsRecord

func (db *DB) ExistsRecord(query string, args ...interface{}) error

func (*DB) QueryModel

func (db *DB) QueryModel(query string, model interface{}, args ...interface{}) error

func (*DB) QueryRecord

func (db *DB) QueryRecord(query string, args ...interface{}) (Record, error)

func (*DB) QueryRecords

func (db *DB) QueryRecords(query string, args ...interface{}) ([]Record, error)

func (*DB) ReturnToPool

func (db *DB) ReturnToPool() bool

type DBConfiguer

type DBConfiguer interface {
	DriverName() string
	IsPing() bool
	String() string
}

type DBMediator

type DBMediator interface {
	DB() *DB
}

type Record

type Record interface {
	Get(key string) interface{}
	GetRaw(key string) *reflect.Value
	GetInString(key string) string
	Each(func(key string, value reflect.Value))
	Merge(r Record)
	Model(dst interface{}) error
}

func NewRecord

func NewRecord(mapToObj ...interface{}) Record

Jump to

Keyboard shortcuts

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