postgresql

package
v0.0.0-...-c835f56 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewZapLogger

func NewZapLogger(logger *zap.Logger) *zapadapter.Logger

Types

type Config

type Config struct {
	Name           string `mapstructure:"name"`
	Hostname       string `mapstructure:"hostname"`
	Port           string `mapstructure:"port"`
	Username       string `mapstructure:"username"`
	Password       string `mapstructure:"password"`
	SSLMode        string `mapstructure:"sslmode"`
	LogLevel       string `mapstructure:"log_level"`
	MinConnections int32  `mapstructure:"min_connections"`
	MaxConnections int32  `mapstructure:"max_connections"`
}

Config defines database configuration, usable for Viper

type Repository

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

Repository is repository implementation based on pgxpool

func New

func New(databaseConfig *Config, logger pgx.Logger) (*Repository, error)

New creates pgx pool from configuration

func (*Repository) CreatePublication

func (repo *Repository) CreatePublication(ctx context.Context, p *entity.Publication) error

CreatePublication inserts new publisher into db

func (*Repository) CreatePublisher

func (repo *Repository) CreatePublisher(ctx context.Context, p *entity.Publisher) error

CreatePublisher inserts new publisher into db

func (*Repository) DeletePublication

func (repo *Repository) DeletePublication(ctx context.Context, uuid uuid.UUID) error

DeletePublication removes Publications from db

func (*Repository) DeletePublisher

func (repo *Repository) DeletePublisher(ctx context.Context, uuid uuid.UUID) error

DeletePublisher removes Publishers from db

func (*Repository) GetPublication

func (repo *Repository) GetPublication(ctx context.Context, uuid uuid.UUID) (*entity.Publication, error)

GetPublication returns Publication from db

func (*Repository) GetPublications

func (repo *Repository) GetPublications(ctx context.Context) ([]*entity.Publication, error)

GetPublications returns list of Publication from db

func (*Repository) GetPublicationsByPublisher

func (repo *Repository) GetPublicationsByPublisher(ctx context.Context, publisherUUID uuid.UUID) ([]*entity.Publication, error)

GetPublicationsByPublisher returns list of Publication filterered by publisher uuid

func (*Repository) GetPublisher

func (repo *Repository) GetPublisher(ctx context.Context, uuid uuid.UUID) (*entity.Publisher, error)

GetPublisher returns Publisher from db

func (*Repository) GetPublishers

func (repo *Repository) GetPublishers(ctx context.Context) ([]*entity.Publisher, error)

GetPublishers returns list of Publisher from db

func (*Repository) Healthcheck

func (repo *Repository) Healthcheck(ctx context.Context) error

Healthcheck is needed for application healtchecks

func (*Repository) UpdatePublication

func (repo *Repository) UpdatePublication(ctx context.Context, p *entity.Publication) error

UpdatePublication updates Publication in db

func (*Repository) UpdatePublisher

func (repo *Repository) UpdatePublisher(ctx context.Context, p *entity.Publisher) error

UpdatePublisher updates Publisher in db

Jump to

Keyboard shortcuts

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