postgres

package
v0.0.0-...-4530040 Latest Latest
Warning

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

Go to latest
Published: May 20, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package postgres provides a PostgreSQL-backed storage implementation for the application. It includes methods for storing, retrieving, and managing URL records in a PostgreSQL database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Storage

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

Storage represents a PostgreSQL-backed storage.

func New

func New(conn string, logger *logging.Logger) (*Storage, error)

New creates a new Storage instance and applies migrations.

func (*Storage) Close

func (p *Storage) Close() error

Close closes the database connection pool.

func (*Storage) DeleteUserURLs

func (p *Storage) DeleteUserURLs(ctx context.Context, ids []string, userID string) error

DeleteUserURLs deletes multiple URLs associated with a user ID.

func (*Storage) Get

func (p *Storage) Get(ctx context.Context, id string) (string, error)

Get retrieves the original URL for a given short URL.

func (*Storage) ListLinksByUserID

func (p *Storage) ListLinksByUserID(ctx context.Context, baseURL, userID string) ([]models.URLRecord, error)

ListLinksByUserID lists all URLs associated with a user ID.

func (*Storage) Ping

func (p *Storage) Ping() error

Ping checks the database connection health.

func (*Storage) Put

func (p *Storage) Put(ctx context.Context, r models.URLRecord) error

Put stores a URLRecord in the database.

func (*Storage) PutBatch

func (p *Storage) PutBatch(ctx context.Context, rr []models.URLRecord) error

PutBatch stores multiple URLRecords in the database.

func (*Storage) Stats

func (p *Storage) Stats(ctx context.Context) (*models.Stats, error)

Stats retrieves count stats: urls and users.

Jump to

Keyboard shortcuts

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