Documentation ¶
Overview ¶
Package database provides real connection to the database.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PgxPoolIface ¶
type PgxPoolIface interface { Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error) Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error) QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row Ping(ctx context.Context) error }
PgxPoolIface defines a little interface for pgxpool functionality. Since in the real implementation we can use pgxpool.Pool, this interface exists mostly for testing purpose.
type URLPostgres ¶
type URLPostgres struct {
// contains filtered or unexported fields
}
URLPostgres is responsible to connect URL with PostgreSQL.
func NewURLPostgres ¶
func NewURLPostgres(pool PgxPoolIface) *URLPostgres
NewURLPostgres creates an instance of URLPostgres.
func (*URLPostgres) GetAll ¶
GetAll gets all URLs from PostgreSQL. If there isn't any data, it returns empty list and nil error.
func (*URLPostgres) GetByCode ¶
GetByCode gets a single URL by its code. It returns entity.ErrNotFound() if the URL can't be found.
Click to show internal directories.
Click to hide internal directories.