Documentation
¶
Index ¶
- Constants
- type PostgresSQL
- func (db *PostgresSQL) Begin() (infrastructure.Transaction, error)
- func (db *PostgresSQL) Close() error
- func (db *PostgresSQL) Exec(query string, args ...interface{}) (sql.Result, error)
- func (db *PostgresSQL) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (db *PostgresSQL) Open() error
- func (db *PostgresSQL) PingContext(ctx context.Context) error
- func (db *PostgresSQL) Query(query string, args ...interface{}) (*sql.Rows, error)
- func (db *PostgresSQL) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
- func (db *PostgresSQL) QueryRow(query string, args ...interface{}) *sql.Row
- func (db *PostgresSQL) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
- func (db *PostgresSQL) Run() error
Constants ¶
const ( DRIVER = "postgres" ErrorNoConfiguration = "No configuration given" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PostgresSQL ¶
PostgresSQL represents postgresql database
func New ¶
func New(conf configuration.DatabaseRepository) (*PostgresSQL, error)
NewPostgresSQL create new instance of PostgresSQL
func (*PostgresSQL) Begin ¶
func (db *PostgresSQL) Begin() (infrastructure.Transaction, error)
Begin starts a transaction. The default isolation level is dependent on the driver.
func (*PostgresSQL) Close ¶
func (db *PostgresSQL) Close() error
Close closes the database and prevents new queries from starting. Close then waits for all queries that have started processing on the server to finish.
It is rare to Close a DB, as the DB handle is meant to be long-lived and shared between many goroutines.
func (*PostgresSQL) Exec ¶
func (db *PostgresSQL) Exec( query string, args ...interface{}, ) (sql.Result, error)
func (*PostgresSQL) ExecContext ¶
func (db *PostgresSQL) ExecContext( ctx context.Context, query string, args ...interface{}, ) (sql.Result, error)
ExecContext executes a query without returning any rows. The args are for any placeholder parameters in the query.
func (*PostgresSQL) Open ¶
func (db *PostgresSQL) Open() error
Open connection to psql and set:
- amount of max open connections
- amount of max idle connections
- max lifetime of connection
return result of ping
func (*PostgresSQL) PingContext ¶
func (db *PostgresSQL) PingContext( ctx context.Context, ) error
PingContext verifies a connection to the database is still alive, establishing a connection if necessary.
func (*PostgresSQL) Query ¶
func (db *PostgresSQL) Query( query string, args ...interface{}, ) (*sql.Rows, error)
func (*PostgresSQL) QueryContext ¶
func (db *PostgresSQL) QueryContext( ctx context.Context, query string, args ...interface{}, ) (*sql.Rows, error)
QueryContext executes a query that returns rows, typically a SELECT. The args are for any placeholder parameters in the query.
func (*PostgresSQL) QueryRow ¶
func (db *PostgresSQL) QueryRow( query string, args ...interface{}) *sql.Row
func (*PostgresSQL) QueryRowContext ¶
func (db *PostgresSQL) QueryRowContext( ctx context.Context, query string, args ...interface{}) *sql.Row
QueryRowContext executes a query that is expected to return at most one row. QueryRowContext always returns a non-nil value. Errors are deferred until Row's Scan method is called. If the query selects no rows, the *Row's Scan will return ErrNoRows. Otherwise, the *Row's Scan scans the first selected row and discards the rest.
func (*PostgresSQL) Run ¶
func (db *PostgresSQL) Run() error