postgres

package
v0.0.0-...-f217533 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDB

func GetDB(config *config.PostgresConfig) (*bun.DB, error)

Types

type PGShortenedURL

type PGShortenedURL struct {
	bun.BaseModel `bun:"table:short_url,alias:surl"`
	URL           string    `bun:"url"`
	Domain        string    `bun:"domain"`
	ShortURL      string    `bun:"short_url,pk"`
	Expires       time.Time `bun:"expires"`
	CreatedAt     time.Time `bun:"created_at"`
}

type PGShortenedURLDomainReport

type PGShortenedURLDomainReport struct {
	bun.BaseModel `bun:"table:short_url,alias:surl"`
	Domain        string `bun:"domain"`
	Count         int    `json:"count"`
}

type PGShortenedURLStorage

type PGShortenedURLStorage struct {
	DB *bun.DB
}

func (*PGShortenedURLStorage) GetOriginalURL

func (p *PGShortenedURLStorage) GetOriginalURL(ctx context.Context, shortURL string) (*models.ShortenedURL, error)

GetOriginalURL implements storage.URLStorage.

func (*PGShortenedURLStorage) ReportTopDomains

func (p *PGShortenedURLStorage) ReportTopDomains(ctx context.Context, n int) ([]*models.JSONDomainReport, error)

func (*PGShortenedURLStorage) StoreShortURL

func (p *PGShortenedURLStorage) StoreShortURL(ctx context.Context, shortenedURL *models.ShortenedURL) error

StoreShortURL implements storage.URLStorage.

Jump to

Keyboard shortcuts

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