repository

package
v0.0.0-...-7a81ec0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPostgresRepo

func NewPostgresRepo() (*pgBookRepository, error)

Types

type InMemRepository

type InMemRepository struct {
	BookList map[string]bookstore.BookDTO
}

Postgres repository

func NewInMemoryRepo

func NewInMemoryRepo() (*InMemRepository, error)

func (InMemRepository) CloseConnection

func (im InMemRepository) CloseConnection()

func (InMemRepository) Delete

func (im InMemRepository) Delete(id string) error

func (InMemRepository) Insert

func (im InMemRepository) Insert(b *bookstore.BookDTO) error

func (InMemRepository) NewBook

func (im InMemRepository) NewBook(title string, author string, copies int, price int64) *bookstore.BookDTO

func (InMemRepository) Select

func (im InMemRepository) Select(id string) (*bookstore.BookDTO, error)

func (InMemRepository) SelectAll

func (im InMemRepository) SelectAll() ([]bookstore.BookDTO, error)

type PostgresConnection

type PostgresConnection struct {
	DB *sql.DB
}

func NewPostgresConnection

func NewPostgresConnection() (c *PostgresConnection, err error)

Connects to a database according to the following environment variables: DRIVER, USER, HOST, PORT, PASSWORD, DBNAME. Example: DRIVER=postgres, USER=db_user, HOST=localhost, PORT=5432, PASSWORD=12345, DBNAME=database_name

func (*PostgresConnection) Close

func (c *PostgresConnection) Close() error

Closes a previously instantiated database connection

Jump to

Keyboard shortcuts

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