postgres

package
v0.0.0-...-2b4ac10 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinConns = 3
	MaxConns = 100
)
View Source
const (
	InitialPassword = "secret"
	UserID          = "e35c3d88-d5b5-4f64-81a1-275a8e560f82"
)
View Source
const (
	AppName = "go-short-url"
)

Variables

This section is empty.

Functions

func Migrate

func Migrate(db *pgxpool.Pool) error

func New

func New(user, pass, host, port, dbName, sslMode string, minConns, maxConns int32) (*pgxpool.Pool, error)

Types

type History

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

func NewHistory

func NewHistory(db *pgxpool.Pool) History

func (History) All

func (h History) All() (model.Histories, error)

func (History) ByShortURLID

func (h History) ByShortURLID(ID uuid.UUID) (model.Histories, error)

func (History) ByShortURLIDAndDates

func (h History) ByShortURLIDAndDates(ID uuid.UUID, from, to int64) (model.Histories, error)

func (History) Create

func (h History) Create(m *model.History) error

func (History) Histories

func (h History) Histories(rows pgx.Rows) (model.Histories, error)

type Permission

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

func NewPermission

func NewPermission(db *pgxpool.Pool) Permission

func (Permission) All

func (p Permission) All() (model.Permissions, error)

func (Permission) ByUserID

func (p Permission) ByUserID(ID uuid.UUID) (model.Permission, error)

func (Permission) Create

func (p Permission) Create(m *model.Permission) error

func (Permission) Delete

func (p Permission) Delete(ID uuid.UUID) error

func (Permission) Update

func (p Permission) Update(m *model.Permission) error

type ShortURL

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

func NewShortURL

func NewShortURL(db *pgxpool.Pool) ShortURL

func (ShortURL) All

func (s ShortURL) All(limit, offset int) (model.ShortURLs, error)

func (ShortURL) ByShort

func (s ShortURL) ByShort(short string) (model.ShortURL, error)

func (ShortURL) Create

func (s ShortURL) Create(m *model.ShortURL) error

func (ShortURL) Delete

func (s ShortURL) Delete(ID uuid.UUID) error

func (ShortURL) IncrementTimes

func (s ShortURL) IncrementTimes(ID uuid.UUID) error

IncrementTimes never will have a race condition b/c postgres has a `READ COMMITTED` isolation level by default. @see https://www.postgresql.org/docs/current/transaction-iso.html#XACT-READ-COMMITTED

func (ShortURL) Update

func (s ShortURL) Update(m *model.ShortURL) error

type User

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

func NewUser

func NewUser(db *pgxpool.Pool) User

func (User) All

func (u User) All() (model.Users, error)

func (User) ByEmail

func (u User) ByEmail(email string) (model.User, error)

func (User) Create

func (u User) Create(m *model.User) error

func (User) Delete

func (u User) Delete(ID uuid.UUID) error

Jump to

Keyboard shortcuts

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