Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewDB ¶ added in v0.14.0
NewDB returns an open database handle of 0 or more underlying PostgreSQL connections
func NewNullInt64 ¶ added in v0.18.0
NewNullInt64 returns a null if i == 0, otherwise it returns the int64 which was input
func NewNullString ¶ added in v0.18.0
func NewNullString(s string) sql.NullString
NewNullString returns a null if s is empty, otherwise it returns the string which was input
Types ¶
type Datastore ¶
type Datastore struct {
// contains filtered or unexported fields
}
Datastore is a concrete implementation for a sql database
func NewDatastore ¶ added in v0.13.0
NewDatastore is an initializer for the Datastore struct
func (*Datastore) BeginTx ¶
BeginTx is a wrapper for sql.DB.BeginTx in order to expose from the Datastore interface
func (*Datastore) CommitTx ¶
CommitTx is a wrapper for sql.Tx.Commit in order to expose from the Datastore interface. Proper error handling is also considered.
type Datastorer ¶ added in v0.15.0
type Datastorer interface {
// DB returns a sql.DB
DB() *sql.DB
// BeginTx starts a sql.Tx using the input context
BeginTx(context.Context) (*sql.Tx, error)
// RollbackTx rolls back the input sql.Tx
RollbackTx(*sql.Tx, error) error
// CommitTx commits the Tx
CommitTx(*sql.Tx) error
}
Datastorer is an interface for working with the Database
type PGDatasourceName ¶ added in v0.19.0
PGDatasourceName is a Postgres datasource name
func NewPGDatasourceName ¶ added in v0.19.0
func NewPGDatasourceName(host, dbname, user, password string, port int) PGDatasourceName
NewPGDatasourceName is an initializer for PGDatasourceName, which is a struct that holds the PostgreSQL datasource name details.
func (PGDatasourceName) String ¶ added in v0.19.0
func (dsn PGDatasourceName) String() string
String returns a formatted PostgreSQL datasource name. If you are using a local db with no password, it removes the password from the string, otherwise the connection will fail.