Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewNullInt64 ¶
NewNullInt64 returns a null if i == 0, otherwise it returns the int64 which was input.
func NewNullString ¶
func NewNullString(s string) sql.NullString
NewNullString returns a null if s is empty, otherwise it returns the string which was input
Types ¶
type Datastorer ¶
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 DefaultDatastore ¶ added in v0.0.2
type DefaultDatastore struct {
// contains filtered or unexported fields
}
DefaultDatastore is a concrete implementation for a sql database
func NewDefaultDatastore ¶ added in v0.0.2
func NewDefaultDatastore(db *sql.DB) DefaultDatastore
NewDefaultDatastore is an initializer for the default Datastore struct
func (DefaultDatastore) BeginTx ¶ added in v0.0.2
BeginTx is a wrapper for sql.DB.BeginTx in order to expose from the Datastore interface
func (DefaultDatastore) CommitTx ¶ added in v0.0.2
func (ds DefaultDatastore) CommitTx(tx *sql.Tx) error
CommitTx is a wrapper for sql.Tx.Commit in order to expose from the Datastore interface. Proper error handling is also considered.
func (DefaultDatastore) DB ¶ added in v0.0.2
func (ds DefaultDatastore) DB() *sql.DB
DB returns the sql.Db for the Datastore struct
func (DefaultDatastore) RollbackTx ¶ added in v0.0.2
func (ds DefaultDatastore) RollbackTx(tx *sql.Tx, err error) error
RollbackTx is a wrapper for sql.Tx.Rollback in order to expose from the Datastore interface. Proper error handling is also considered.
type PGDatasourceName ¶ added in v0.0.2
PGDatasourceName is a Postgres datasource name
func NewPGDatasourceName ¶ added in v0.0.2
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.0.2
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.