db

package
v0.0.0-...-bd2df9c Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Migrate

func Migrate(dbURL string) error

Types

type Comment

type Comment struct {
	ID     uuid.UUID
	LinkID uuid.UUID
}

type CommentParams

type CommentParams struct {
	ID     uuid.UUID
	UserID uuid.UUID
}

type CommentRow

type CommentRow struct {
	ID        uuid.UUID
	LinkSlug  string
	ParentID  uuid.UUID
	Content   string
	CreatedAt time.Time
	UpdatedAt time.Time
	Username  string
	Replies   int64
	Score     int64
	UserVote  int16
	Children  []CommentRow
}

type ControversialCommentsParams

type ControversialCommentsParams struct {
	Slug   string
	UserID uuid.UUID
}

type ControversialLinksParams

type ControversialLinksParams struct {
	UserID uuid.UUID
	Limit  int32
	Offset int32
}

type CreateCommentParams

type CreateCommentParams struct {
	UserID  uuid.UUID
	LinkID  uuid.UUID
	Content string
}

type CreateLikeParams

type CreateLikeParams struct {
	UserID uuid.UUID
	LinkID uuid.UUID
}

type CreateLinkParams

type CreateLinkParams struct {
	UserID uuid.UUID
	Title  string
	Url    string
	Slug   string
}

type CreateReplyParams

type CreateReplyParams struct {
	UserID   uuid.UUID
	LinkID   uuid.UUID
	ParentID uuid.UUID
	Content  string
}

type CreateUserParams

type CreateUserParams struct {
	Avatar   string
	Email    string
	Username string
	Password string
}

type CreateUserTokenParams

type CreateUserTokenParams struct {
	UserID  uuid.UUID
	Token   string
	Context string
}

type CreateVoteParams

type CreateVoteParams struct {
	UserID    uuid.UUID
	CommentID uuid.UUID
	Vote      int32
}

type DBTX

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

type DeleteLikeParams

type DeleteLikeParams struct {
	UserID uuid.UUID
	LinkID uuid.UUID
}

type DeleteUserTokenParams

type DeleteUserTokenParams struct {
	Token   string
	Context string
}

type LatestCommentsParams

type LatestCommentsParams struct {
	Slug   string
	UserID uuid.UUID
}

type LatestLinksParams

type LatestLinksParams struct {
	UserID uuid.UUID
	Limit  int32
	Offset int32
}
type Link struct {
	ID uuid.UUID
}

type LinkBySlugParams

type LinkBySlugParams struct {
	UserID uuid.UUID
	Slug   string
}

type LinkLikesAndLikedParams

type LinkLikesAndLikedParams struct {
	LinkID uuid.UUID
	UserID uuid.UUID
}

type LinkLikesAndLikedRow

type LinkLikesAndLikedRow struct {
	Likes int64
	Liked bool
}

type LinkRow

type LinkRow struct {
	ID        uuid.UUID
	Title     string
	Url       string
	Slug      string
	CreatedAt time.Time
	UpdatedAt time.Time
	Username  string
	Comments  int64
	Likes     int64
	Liked     bool
}

type PopularCommentsParams

type PopularCommentsParams struct {
	Slug   string
	UserID uuid.UUID
}

type PopularLinksParams

type PopularLinksParams struct {
	UserID uuid.UUID
	Limit  int32
	Offset int32
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) Comment

func (q *Queries) Comment(ctx context.Context, arg CommentParams) (CommentRow, error)

func (*Queries) CommentList

func (q *Queries) CommentList(ctx context.Context) ([]Comment, error)

func (*Queries) ControversialComments

func (q *Queries) ControversialComments(ctx context.Context, arg ControversialCommentsParams) ([]CommentRow, error)
func (q *Queries) ControversialLinks(ctx context.Context, arg ControversialLinksParams) ([]LinkRow, error)
func (q *Queries) CountLinks(ctx context.Context) (int64, error)

func (*Queries) CreateComment

func (q *Queries) CreateComment(ctx context.Context, arg CreateCommentParams) error

func (*Queries) CreateLike

func (q *Queries) CreateLike(ctx context.Context, arg CreateLikeParams) error
func (q *Queries) CreateLink(ctx context.Context, arg CreateLinkParams) (string, error)

func (*Queries) CreateReply

func (q *Queries) CreateReply(ctx context.Context, arg CreateReplyParams) error

func (*Queries) CreateUser

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

func (*Queries) CreateUserToken

func (q *Queries) CreateUserToken(ctx context.Context, arg CreateUserTokenParams) (string, error)

func (*Queries) CreateVote

func (q *Queries) CreateVote(ctx context.Context, arg CreateVoteParams) error

func (*Queries) DeleteLike

func (q *Queries) DeleteLike(ctx context.Context, arg DeleteLikeParams) error

func (*Queries) DeleteUserToken

func (q *Queries) DeleteUserToken(ctx context.Context, arg DeleteUserTokenParams) error

func (*Queries) EmailExists

func (q *Queries) EmailExists(ctx context.Context, email string) (bool, error)

func (*Queries) LatestComments

func (q *Queries) LatestComments(ctx context.Context, arg LatestCommentsParams) ([]CommentRow, error)
func (q *Queries) LatestLinks(ctx context.Context, arg LatestLinksParams) ([]LinkRow, error)

func (*Queries) LinkBySlug

func (q *Queries) LinkBySlug(ctx context.Context, arg LinkBySlugParams) (LinkRow, error)

func (*Queries) LinkIDBySlug

func (q *Queries) LinkIDBySlug(ctx context.Context, slug string) (uuid.UUID, error)

func (*Queries) LinkLikesAndLiked

func (q *Queries) LinkLikesAndLiked(ctx context.Context, arg LinkLikesAndLikedParams) (LinkLikesAndLikedRow, error)
func (q *Queries) LinkList(ctx context.Context) ([]Link, error)

func (*Queries) PopularComments

func (q *Queries) PopularComments(ctx context.Context, arg PopularCommentsParams) ([]CommentRow, error)
func (q *Queries) PopularLinks(ctx context.Context, arg PopularLinksParams) ([]LinkRow, error)

func (*Queries) UserByID

func (q *Queries) UserByID(ctx context.Context, id uuid.UUID) (UserByIDRow, error)

func (*Queries) UserIDAndPasswordByEmail

func (q *Queries) UserIDAndPasswordByEmail(ctx context.Context, email string) (UserIDAndPasswordByEmailRow, error)

func (*Queries) UserIDByToken

func (q *Queries) UserIDByToken(ctx context.Context, arg UserIDByTokenParams) (uuid.UUID, error)

func (*Queries) UserList

func (q *Queries) UserList(ctx context.Context) ([]UserRow, error)

func (*Queries) UserProfile

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

func (*Queries) UsernameExists

func (q *Queries) UsernameExists(ctx context.Context, username string) (bool, error)

func (*Queries) WithTx

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

type UserByIDRow

type UserByIDRow struct {
	ID          uuid.UUID
	Avatar      string
	Username    string
	Email       string
	ConfirmedAt pgtype.Timestamptz
	CreatedAt   pgtype.Timestamptz
	UpdatedAt   pgtype.Timestamptz
}

type UserIDAndPasswordByEmailRow

type UserIDAndPasswordByEmailRow struct {
	ID       uuid.UUID
	Password string
}

type UserIDByTokenParams

type UserIDByTokenParams struct {
	Token   string
	Context string
}

type UserProfile

type UserProfile struct {
	ID       uuid.UUID
	Avatar   string
	Username string
	Likes    int64
	Links    int64
	Comments int64
}

type UserRow

type UserRow struct {
	ID uuid.UUID
}

Jump to

Keyboard shortcuts

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