postgres

package
v0.0.0-...-cddfa53 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package postgres handles all requests down to database.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBeginTransaction returned when transaction fails from beginning.
	ErrBeginTransaction = errors.New("failed to begin transaction")

	// ErrCommitTransaction returned when commit transaction fails.
	ErrCommitTransaction = errors.New("failed to commit transaction")
)

Functions

func Connect

func Connect(dsn string) (*pgxpool.Pool, error)

Connect connet to postgres driver with giving dsn.

func FormatAnd

func FormatAnd(column string, value string) string

FormatAnd returns a SQL string for a giving column and string value.

func FormatAndInt

func FormatAndInt(column string, value int) string

FormatAndInt returns a SQL string for a giving column and integer value.

func FormatLimitOffset

func FormatLimitOffset(limit int, offset int) string

FormatLimitOffset returns a SQL string for a given limit & offset.

func FormatSort

func FormatSort(column string) string

FormatSort returns a SQL string for a giving column.

func NewCartStore

func NewCartStore(db *pgxpool.Pool) cartStore

NewCartStore returns a new instance of CartStore.

func NewCategoryStore

func NewCategoryStore(db *pgxpool.Pool) categoryStore

NewCategoryStore returns a new instance of CategoriesStore.

func NewProductStore

func NewProductStore(db *pgxpool.Pool) productStore

NewProductStore returns a new instance of ProductStore.

func NewSearchStore

func NewSearchStore(db *pgxpool.Pool) searchStore

NewSearchStore returns a new instance of SearchStore.

func NewTokenStore

func NewTokenStore(db *pgxpool.Pool) tokenStore

NewTokenStore returns a new instance of TokenStore

func NewUserStore

func NewUserStore(db *pgxpool.Pool) userStore

NewUserStore returns a new instance of UsersStore.

Types

type Postgres

type Postgres struct {
	DB *pgxpool.Pool
}

Postgres represents Postgres connection pool.

func New

func New(dsn string) (Postgres, error)

New returns a new instace of postgres.

func (*Postgres) Close

func (p *Postgres) Close() error

Close closes postgres connection.

func (*Postgres) Ping

func (p *Postgres) Ping(ctx context.Context) error

Ping test postgres connection.

Jump to

Keyboard shortcuts

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