Documentation
¶
Index ¶
- type PostgresProvider
- type PostgresRepository
- func (r *PostgresRepository) BeginTx(ctx context.Context) (repository.Repository, error)
- func (r *PostgresRepository) CommitTx(ctx context.Context) error
- func (r *PostgresRepository) CreateComment(ctx context.Context, comment *models.Comment) error
- func (r *PostgresRepository) CreateVote(ctx context.Context, vote *models.Vote) error
- func (r *PostgresRepository) DeleteComment(ctx context.Context, id string, userID string) error
- func (r *PostgresRepository) DeleteVote(ctx context.Context, commentID, userID string) error
- func (r *PostgresRepository) GetCommentByID(ctx context.Context, id string) (*models.Comment, error)
- func (r *PostgresRepository) GetCommentChildren(ctx context.Context, parentID string, maxDepth int) ([]*models.Comment, error)
- func (r *PostgresRepository) GetCommentPath(ctx context.Context, commentID string) ([]*models.Comment, error)
- func (r *PostgresRepository) GetCommentStats(ctx context.Context, rootID string) (*models.CommentStats, error)
- func (r *PostgresRepository) GetCommentTree(ctx context.Context, rootID string, maxDepth int, sortBy string) ([]*models.CommentTree, error)
- func (r *PostgresRepository) GetCommentVotes(ctx context.Context, commentID string) ([]*models.Vote, error)
- func (r *PostgresRepository) GetComments(ctx context.Context, filter *models.CommentFilter) ([]*models.Comment, error)
- func (r *PostgresRepository) GetCommentsByRootID(ctx context.Context, rootID string, filter *models.CommentFilter) ([]*models.Comment, error)
- func (r *PostgresRepository) GetCommentsByUserID(ctx context.Context, userID string, filter *models.CommentFilter) ([]*models.Comment, error)
- func (r *PostgresRepository) GetCommentsWithUserVotes(ctx context.Context, rootID, userID string, filter *models.CommentFilter) ([]*models.Comment, map[string]*models.Vote, error)
- func (r *PostgresRepository) GetTopComments(ctx context.Context, rootID string, limit int, timeRange string) ([]*models.Comment, error)
- func (r *PostgresRepository) GetUserCommentCount(ctx context.Context, userID string) (int64, error)
- func (r *PostgresRepository) GetUserVote(ctx context.Context, commentID, userID string) (*models.Vote, error)
- func (r *PostgresRepository) PurgeDeletedComments(ctx context.Context, olderThan int) (int64, error)
- func (r *PostgresRepository) RecalculateCommentScores(ctx context.Context) error
- func (r *PostgresRepository) RollbackTx(ctx context.Context) error
- func (r *PostgresRepository) UpdateComment(ctx context.Context, id string, updates *models.UpdateCommentRequest) error
- func (r *PostgresRepository) UpdateCommentScores(ctx context.Context, commentIDs []string) error
- func (r *PostgresRepository) UpdateVote(ctx context.Context, commentID, userID string, voteType models.VoteType) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PostgresProvider ¶
type PostgresProvider struct {
// contains filtered or unexported fields
}
PostgresProvider implements the RepositoryProvider interface
func NewPostgresProvider ¶
func NewPostgresProvider(db *sqlx.DB) *PostgresProvider
NewPostgresProvider creates a new PostgreSQL repository provider
func (*PostgresProvider) Close ¶
func (p *PostgresProvider) Close() error
Close closes the database connection
func (*PostgresProvider) GetCommentRepository ¶
func (p *PostgresProvider) GetCommentRepository() repository.CommentRepository
GetCommentRepository returns a PostgreSQL comment repository
func (*PostgresProvider) Health ¶
func (p *PostgresProvider) Health() error
Health checks if the database is healthy
func (*PostgresProvider) Migrate ¶
func (p *PostgresProvider) Migrate() error
Migrate runs database migrations
type PostgresRepository ¶
type PostgresRepository struct {
// contains filtered or unexported fields
}
PostgresRepository implements the CommentRepository interface for PostgreSQL
func (*PostgresRepository) BeginTx ¶
func (r *PostgresRepository) BeginTx(ctx context.Context) (repository.Repository, error)
Transaction support
func (*PostgresRepository) CommitTx ¶
func (r *PostgresRepository) CommitTx(ctx context.Context) error
func (*PostgresRepository) CreateComment ¶
CreateComment creates a new comment
func (*PostgresRepository) CreateVote ¶
Vote operations
func (*PostgresRepository) DeleteComment ¶
DeleteComment soft deletes a comment
func (*PostgresRepository) DeleteVote ¶
func (r *PostgresRepository) DeleteVote(ctx context.Context, commentID, userID string) error
DeleteVote removes a user's vote
func (*PostgresRepository) GetCommentByID ¶
func (r *PostgresRepository) GetCommentByID(ctx context.Context, id string) (*models.Comment, error)
GetCommentByID retrieves a comment by its ID
func (*PostgresRepository) GetCommentChildren ¶
func (r *PostgresRepository) GetCommentChildren(ctx context.Context, parentID string, maxDepth int) ([]*models.Comment, error)
GetCommentChildren retrieves child comments up to maxDepth
func (*PostgresRepository) GetCommentPath ¶
func (r *PostgresRepository) GetCommentPath(ctx context.Context, commentID string) ([]*models.Comment, error)
GetCommentPath retrieves the path from root to a specific comment
func (*PostgresRepository) GetCommentStats ¶
func (r *PostgresRepository) GetCommentStats(ctx context.Context, rootID string) (*models.CommentStats, error)
GetCommentStats retrieves statistics for a root
func (*PostgresRepository) GetCommentTree ¶
func (r *PostgresRepository) GetCommentTree(ctx context.Context, rootID string, maxDepth int, sortBy string) ([]*models.CommentTree, error)
GetCommentTree builds a hierarchical tree structure
func (*PostgresRepository) GetCommentVotes ¶
func (r *PostgresRepository) GetCommentVotes(ctx context.Context, commentID string) ([]*models.Vote, error)
GetCommentVotes retrieves all votes for a comment
func (*PostgresRepository) GetComments ¶
func (r *PostgresRepository) GetComments(ctx context.Context, filter *models.CommentFilter) ([]*models.Comment, error)
GetComments retrieves comments based on filter
func (*PostgresRepository) GetCommentsByRootID ¶
func (r *PostgresRepository) GetCommentsByRootID(ctx context.Context, rootID string, filter *models.CommentFilter) ([]*models.Comment, error)
GetCommentsByRootID retrieves comments for a specific root
func (*PostgresRepository) GetCommentsByUserID ¶
func (r *PostgresRepository) GetCommentsByUserID(ctx context.Context, userID string, filter *models.CommentFilter) ([]*models.Comment, error)
GetCommentsByUserID retrieves comments by a specific user
func (*PostgresRepository) GetCommentsWithUserVotes ¶
func (r *PostgresRepository) GetCommentsWithUserVotes(ctx context.Context, rootID, userID string, filter *models.CommentFilter) ([]*models.Comment, map[string]*models.Vote, error)
GetCommentsWithUserVotes retrieves comments with user's votes in a single query
func (*PostgresRepository) GetTopComments ¶
func (r *PostgresRepository) GetTopComments(ctx context.Context, rootID string, limit int, timeRange string) ([]*models.Comment, error)
GetTopComments retrieves top comments based on score within time range
func (*PostgresRepository) GetUserCommentCount ¶
GetUserCommentCount retrieves the number of comments by a user
func (*PostgresRepository) GetUserVote ¶
func (r *PostgresRepository) GetUserVote(ctx context.Context, commentID, userID string) (*models.Vote, error)
GetUserVote retrieves a user's vote for a comment
func (*PostgresRepository) PurgeDeletedComments ¶
func (r *PostgresRepository) PurgeDeletedComments(ctx context.Context, olderThan int) (int64, error)
PurgeDeletedComments permanently deletes soft-deleted comments older than specified days
func (*PostgresRepository) RecalculateCommentScores ¶
func (r *PostgresRepository) RecalculateCommentScores(ctx context.Context) error
RecalculateCommentScores recalculates all comment scores
func (*PostgresRepository) RollbackTx ¶
func (r *PostgresRepository) RollbackTx(ctx context.Context) error
func (*PostgresRepository) UpdateComment ¶
func (r *PostgresRepository) UpdateComment(ctx context.Context, id string, updates *models.UpdateCommentRequest) error
UpdateComment updates a comment's content
func (*PostgresRepository) UpdateCommentScores ¶
func (r *PostgresRepository) UpdateCommentScores(ctx context.Context, commentIDs []string) error
UpdateCommentScores recalculates scores for specified comments
func (*PostgresRepository) UpdateVote ¶
func (r *PostgresRepository) UpdateVote(ctx context.Context, commentID, userID string, voteType models.VoteType) error
UpdateVote updates or creates a vote