postgres

package
v0.0.0-...-221c55c Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustSetupDB

func MustSetupDB(dsn string, maxOpenConns, maxIdleConns int, enableMigration bool, migrations string) *sql.DB

MustSetupDB opens DB connection and runs migrations.

Types

type Config

type Config struct {
	Host, Port                 string
	User, Password             string
	DBName                     string
	MaxOpenConns, MaxIdleConns int
	EnableMigration            bool
	MigrationsDir              string
}

type PG

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

func MustSetupStorage

func MustSetupStorage(config Config) PG

func New

func New(db *sql.DB) PG

New creates postgres storage.

func (PG) Check

func (p PG) Check(ctx context.Context) error

func (PG) Close

func (p PG) Close() error

func (PG) Create

func (p PG) Create(ctx context.Context, a *model.Announcement) error

func (PG) Delete

func (p PG) Delete(ctx context.Context, id string) error

func (PG) GetAll

func (p PG) GetAll(ctx context.Context, filter model.Filter) ([]*model.Announcement, error)

func (PG) InTx

func (p PG) InTx(ctx context.Context, action func(s storage.AnnouncementStorage) error) error

Jump to

Keyboard shortcuts

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