Documentation ¶
Index ¶
- func NewPostgresRepo() (*pgBookRepository, error)
- type InMemRepository
- func (im InMemRepository) CloseConnection()
- func (im InMemRepository) Delete(id string) error
- func (im InMemRepository) Insert(b *bookstore.BookDTO) error
- func (im InMemRepository) NewBook(title string, author string, copies int, price int64) *bookstore.BookDTO
- func (im InMemRepository) Select(id string) (*bookstore.BookDTO, error)
- func (im InMemRepository) SelectAll() ([]bookstore.BookDTO, error)
- type PostgresConnection
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewPostgresRepo ¶
func NewPostgresRepo() (*pgBookRepository, error)
Types ¶
type InMemRepository ¶
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
type PostgresConnection ¶
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
Click to show internal directories.
Click to hide internal directories.