db

package
v0.0.0-...-83625b3 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2018 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectToDB

func ConnectToDB(connectString string) (*sql.DB, error)

func ConstraintErrorConverter

func ConstraintErrorConverter(msgMap map[string]string) func(*pq.Error) errors.Error

ConstraintErrorConverter converts a constraint violation error into a user-friendly message.

func ConvertDBError

func ConvertDBError(err error, conv func(*pq.Error) errors.Error) error

ConvertDBError converts an error with conv if that error is *pq.Error.

Useful when processing database errors (e.g. constraint violations), so the user can get a nice error message.

func DBErrorToVerboseString

func DBErrorToVerboseString(err *pq.Error) string

DBErrorToVerboseString is a helper function that converts a *pq.Error into a detailed string.

func RetryDBConn

func RetryDBConn(connectString string, tries uint) *sql.DB

Types

type DB

type DB interface {
	Exec(string, ...interface{}) (sql.Result, error)
	Query(string, ...interface{}) (*sql.Rows, error)
	QueryRow(string, ...interface{}) *sql.Row
	Prepare(string) (*sql.Stmt, error)
}

DB is an abstraction over *sql.DB and *sql.Tx

type DBSchemaProvider

type DBSchemaProvider interface {
	Name() string
	DBSchema() SchemaGenerations
}

type Schema

type Schema func(conn DB) error

type SchemaGenerations

type SchemaGenerations []Schema

func DefineSchemaGenerations

func DefineSchemaGenerations(gens ...Schema) SchemaGenerations

func (SchemaGenerations) UpgradeFrom

func (g SchemaGenerations) UpgradeFrom(last int, conn DB) (int, error)

Jump to

Keyboard shortcuts

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