pgsql

package module
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2018 License: MIT Imports: 5 Imported by: 8

README

pgsql

Build Status Coverage Status Go Report Card GoDoc

pgsql is the helper functions for postgres

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsInvalidTextRepresentation added in v0.2.2

func IsInvalidTextRepresentation(err error) bool

IsInvalidTextRepresentation checks is error an invalid_text_representation

func IsUniqueViolation

func IsUniqueViolation(err error, constraint ...string) bool

IsUniqueViolation checks is error an unique_violation with given constraint, constraint can be empty to ignore constraint name checks

func RunInTx

func RunInTx(db BeginTxer, opts *TxOptions, fn func(*sql.Tx) error) error

RunInTx runs fn inside retryable transaction

func RunInTxContext

func RunInTxContext(ctx context.Context, db BeginTxer, opts *TxOptions, fn func(*sql.Tx) error) error

RunInTxContext runs fn inside retryable transaction with context

Types

type BeginTxer added in v0.2.1

type BeginTxer interface {
	BeginTx(context.Context, *sql.TxOptions) (*sql.Tx, error)
}

BeginTxer type

type Time added in v0.2.3

type Time struct {
	time.Time
}

Time is the time.Time but can scan null into empty

func (*Time) Scan added in v0.2.3

func (t *Time) Scan(src interface{}) error

Scan implements Scanner interface

func (Time) Value added in v0.2.3

func (t Time) Value() (driver.Value, error)

Value implements Valuer interface

type TxOptions

type TxOptions struct {
	sql.TxOptions
	MaxAttempts int
}

TxOptions is the transaction options

Jump to

Keyboard shortcuts

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