db

package
v0.0.0-...-ee7ed0d Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreatePasteParams

type CreatePasteParams struct {
	ID           string           `json:"id"`
	Title        pgtype.Text      `json:"title"`
	Content      string           `json:"content"`
	Syntax       pgtype.Text      `json:"syntax"`
	IsPublic     bool             `json:"is_public"`
	IsCompressed bool             `json:"is_compressed"`
	ExpiresAt    pgtype.Timestamp `json:"expires_at"`
}

type CreateQRCodeParams

type CreateQRCodeParams struct {
	ID        string `json:"id"`
	Text      string `json:"text"`
	Format    string `json:"format"`
	Size      int32  `json:"size"`
	ImageData []byte `json:"image_data"`
}

type CreateQRCodeRow

type CreateQRCodeRow struct {
	ID        string           `json:"id"`
	Text      string           `json:"text"`
	Format    string           `json:"format"`
	Size      int32            `json:"size"`
	CreatedAt pgtype.Timestamp `json:"created_at"`
}

type CreateShortURLParams

type CreateShortURLParams struct {
	Code        string           `json:"code"`
	OriginalUrl string           `json:"original_url"`
	Alias       pgtype.Text      `json:"alias"`
	Clicks      int64            `json:"clicks"`
	IsPublic    bool             `json:"is_public"`
	ExpiresAt   pgtype.Timestamp `json:"expires_at"`
}

type CreateTodoParams

type CreateTodoParams struct {
	Title       string      `json:"title"`
	Description pgtype.Text `json:"description"`
	Completed   bool        `json:"completed"`
	UserID      int64       `json:"user_id"`
}

type CreateURLClickParams

type CreateURLClickParams struct {
	ShortUrlID int64       `json:"short_url_id"`
	Referrer   pgtype.Text `json:"referrer"`
	UserAgent  pgtype.Text `json:"user_agent"`
	IpAddress  pgtype.Text `json:"ip_address"`
}

type CreateUserParams

type CreateUserParams struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type CreateUserRow

type CreateUserRow struct {
	ID        int64            `json:"id"`
	Username  string           `json:"username"`
	CreatedAt pgtype.Timestamp `json:"created_at"`
	UpdatedAt pgtype.Timestamp `json:"updated_at"`
}

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

type DeleteTodoParams

type DeleteTodoParams struct {
	ID     int64 `json:"id"`
	UserID int64 `json:"user_id"`
}

type GetTodoByIDParams

type GetTodoByIDParams struct {
	ID     int64 `json:"id"`
	UserID int64 `json:"user_id"`
}

type GetUserByIDRow

type GetUserByIDRow struct {
	ID        int64            `json:"id"`
	Username  string           `json:"username"`
	CreatedAt pgtype.Timestamp `json:"created_at"`
	UpdatedAt pgtype.Timestamp `json:"updated_at"`
}

type ListTodosParams

type ListTodosParams struct {
	UserID int64 `json:"user_id"`
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

type Paste

type Paste struct {
	ID           string           `json:"id"`
	Title        pgtype.Text      `json:"title"`
	Content      string           `json:"content"`
	Syntax       pgtype.Text      `json:"syntax"`
	IsPublic     bool             `json:"is_public"`
	IsCompressed bool             `json:"is_compressed"`
	ExpiresAt    pgtype.Timestamp `json:"expires_at"`
	CreatedAt    pgtype.Timestamp `json:"created_at"`
	UpdatedAt    pgtype.Timestamp `json:"updated_at"`
}

type QrCode

type QrCode struct {
	ID        string           `json:"id"`
	Text      string           `json:"text"`
	Format    string           `json:"format"`
	Size      int32            `json:"size"`
	ImageData []byte           `json:"image_data"`
	CreatedAt pgtype.Timestamp `json:"created_at"`
}

type Querier

type Querier interface {
	CountTodos(ctx context.Context, userID int64) (int64, error)
	// Pastebin Queries
	CreatePaste(ctx context.Context, arg CreatePasteParams) (Paste, error)
	// QR Code Queries
	CreateQRCode(ctx context.Context, arg CreateQRCodeParams) (CreateQRCodeRow, error)
	// URL Shortener Queries
	CreateShortURL(ctx context.Context, arg CreateShortURLParams) (ShortUrl, error)
	CreateTodo(ctx context.Context, arg CreateTodoParams) (Todo, error)
	CreateURLClick(ctx context.Context, arg CreateURLClickParams) error
	CreateUser(ctx context.Context, arg CreateUserParams) (CreateUserRow, error)
	DeleteExpiredPastes(ctx context.Context) error
	DeleteExpiredShortURLs(ctx context.Context) error
	DeletePaste(ctx context.Context, id string) error
	DeleteTodo(ctx context.Context, arg DeleteTodoParams) error
	GetPasteByID(ctx context.Context, id string) (Paste, error)
	GetQRCodeByID(ctx context.Context, id string) (QrCode, error)
	GetShortURLByCode(ctx context.Context, code string) (ShortUrl, error)
	GetTodoByID(ctx context.Context, arg GetTodoByIDParams) (Todo, error)
	GetUserByID(ctx context.Context, id int64) (GetUserByIDRow, error)
	GetUserByUsername(ctx context.Context, username string) (User, error)
	IncrementShortURLClicks(ctx context.Context, id int64) error
	ListRecentPastes(ctx context.Context, limit int32) ([]Paste, error)
	ListTodos(ctx context.Context, arg ListTodosParams) ([]Todo, error)
	UpdateTodo(ctx context.Context, arg UpdateTodoParams) (Todo, error)
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) CountTodos

func (q *Queries) CountTodos(ctx context.Context, userID int64) (int64, error)

func (*Queries) CreatePaste

func (q *Queries) CreatePaste(ctx context.Context, arg CreatePasteParams) (Paste, error)

Pastebin Queries

func (*Queries) CreateQRCode

func (q *Queries) CreateQRCode(ctx context.Context, arg CreateQRCodeParams) (CreateQRCodeRow, error)

QR Code Queries

func (*Queries) CreateShortURL

func (q *Queries) CreateShortURL(ctx context.Context, arg CreateShortURLParams) (ShortUrl, error)

URL Shortener Queries

func (*Queries) CreateTodo

func (q *Queries) CreateTodo(ctx context.Context, arg CreateTodoParams) (Todo, error)

func (*Queries) CreateURLClick

func (q *Queries) CreateURLClick(ctx context.Context, arg CreateURLClickParams) error

func (*Queries) CreateUser

func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (CreateUserRow, error)

func (*Queries) DeleteExpiredPastes

func (q *Queries) DeleteExpiredPastes(ctx context.Context) error

func (*Queries) DeleteExpiredShortURLs

func (q *Queries) DeleteExpiredShortURLs(ctx context.Context) error

func (*Queries) DeletePaste

func (q *Queries) DeletePaste(ctx context.Context, id string) error

func (*Queries) DeleteTodo

func (q *Queries) DeleteTodo(ctx context.Context, arg DeleteTodoParams) error

func (*Queries) GetPasteByID

func (q *Queries) GetPasteByID(ctx context.Context, id string) (Paste, error)

func (*Queries) GetQRCodeByID

func (q *Queries) GetQRCodeByID(ctx context.Context, id string) (QrCode, error)

func (*Queries) GetShortURLByCode

func (q *Queries) GetShortURLByCode(ctx context.Context, code string) (ShortUrl, error)

func (*Queries) GetTodoByID

func (q *Queries) GetTodoByID(ctx context.Context, arg GetTodoByIDParams) (Todo, error)

func (*Queries) GetUserByID

func (q *Queries) GetUserByID(ctx context.Context, id int64) (GetUserByIDRow, error)

func (*Queries) GetUserByUsername

func (q *Queries) GetUserByUsername(ctx context.Context, username string) (User, error)

func (*Queries) IncrementShortURLClicks

func (q *Queries) IncrementShortURLClicks(ctx context.Context, id int64) error

func (*Queries) ListRecentPastes

func (q *Queries) ListRecentPastes(ctx context.Context, limit int32) ([]Paste, error)

func (*Queries) ListTodos

func (q *Queries) ListTodos(ctx context.Context, arg ListTodosParams) ([]Todo, error)

func (*Queries) UpdateTodo

func (q *Queries) UpdateTodo(ctx context.Context, arg UpdateTodoParams) (Todo, error)

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type ShortUrl

type ShortUrl struct {
	ID          int64            `json:"id"`
	Code        string           `json:"code"`
	OriginalUrl string           `json:"original_url"`
	Alias       pgtype.Text      `json:"alias"`
	Clicks      int64            `json:"clicks"`
	IsPublic    bool             `json:"is_public"`
	ExpiresAt   pgtype.Timestamp `json:"expires_at"`
	CreatedAt   pgtype.Timestamp `json:"created_at"`
	UpdatedAt   pgtype.Timestamp `json:"updated_at"`
}

type Todo

type Todo struct {
	ID          int64            `json:"id"`
	Title       string           `json:"title"`
	Description pgtype.Text      `json:"description"`
	Completed   bool             `json:"completed"`
	UserID      int64            `json:"user_id"`
	CreatedAt   pgtype.Timestamp `json:"created_at"`
	UpdatedAt   pgtype.Timestamp `json:"updated_at"`
}

type UpdateTodoParams

type UpdateTodoParams struct {
	Title       string      `json:"title"`
	Description pgtype.Text `json:"description"`
	Completed   bool        `json:"completed"`
	ID          int64       `json:"id"`
	UserID      int64       `json:"user_id"`
}

type UrlClick

type UrlClick struct {
	ID         int64            `json:"id"`
	ShortUrlID int64            `json:"short_url_id"`
	Referrer   pgtype.Text      `json:"referrer"`
	UserAgent  pgtype.Text      `json:"user_agent"`
	IpAddress  pgtype.Text      `json:"ip_address"`
	ClickedAt  pgtype.Timestamp `json:"clicked_at"`
}

type User

type User struct {
	ID        int64            `json:"id"`
	Username  string           `json:"username"`
	Password  string           `json:"password"`
	CreatedAt pgtype.Timestamp `json:"created_at"`
	UpdatedAt pgtype.Timestamp `json:"updated_at"`
}

Jump to

Keyboard shortcuts

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