Documentation ¶
Index ¶
- func ConnectToDB(connectString string) (*sql.DB, error)
- func ConstraintErrorConverter(msgMap map[string]string) func(*pq.Error) errors.Error
- func ConvertDBError(err error, conv func(*pq.Error) errors.Error) error
- func DBErrorToVerboseString(err *pq.Error) string
- func RetryDBConn(connectString string, tries uint) *sql.DB
- type DB
- type DBSchemaProvider
- type Schema
- type SchemaGenerations
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConstraintErrorConverter ¶
ConstraintErrorConverter converts a constraint violation error into a user-friendly message.
func ConvertDBError ¶
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 ¶
DBErrorToVerboseString is a helper function that converts a *pq.Error into a detailed string.
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 SchemaGenerations ¶
type SchemaGenerations []Schema
func DefineSchemaGenerations ¶
func DefineSchemaGenerations(gens ...Schema) SchemaGenerations
func (SchemaGenerations) UpgradeFrom ¶
func (g SchemaGenerations) UpgradeFrom(last int, conn DB) (int, error)
Click to show internal directories.
Click to hide internal directories.