postgres

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MigrateDB

func MigrateDB(db *sql.DB, migrationsPath string) error

MigrateDB applies the database migrations into the supplied DB

func NewDb

func NewDb(configs ...ConfigOption) (*sql.DB, error)

NewDb returns a new database access object for a postgres database, from a set of configuration options.

Types

type ConfigOption

type ConfigOption func(configBuilder)

ConfigOption represents a function to configure the postgres connection

func Credentials

func Credentials(username, password string) ConfigOption

Credentials configures postgres with username and password

func DbName

func DbName(dbName string) ConfigOption

DbName configures postgres with a database name

func HostAndPort

func HostAndPort(hostname string, port int) ConfigOption

HostAndPort configures postgres with hostname and port number

func SslDisabled

func SslDisabled() ConfigOption

SslDisabled configures postgres to not enable SSL

type TodosRepository

type TodosRepository struct {
	// contains filtered or unexported fields
}

TodosRepository is a postgres implementation of a base todos.TodosRepository

func NewTodosRepository

func NewTodosRepository(db *sql.DB) *TodosRepository

NewTodosRepository creates a new Todos repository backed by a Postgres db.

func (*TodosRepository) GetAll

func (repository *TodosRepository) GetAll() ([]todo.Todo, error)

GetAll returns all todos from the database.

Jump to

Keyboard shortcuts

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