Documentation ¶
Index ¶
- type Memory
- func (r *Memory) Add(_ context.Context, newPost *post.Post) (postID uuid.UUID, err error)
- func (r *Memory) AddComment(_ context.Context, postID uuid.UUID, newComment *post.Comment) (commentID uuid.UUID, err error)
- func (r *Memory) AddVote(_ context.Context, postID uuid.UUID, vote *post.Vote) error
- func (r *Memory) Delete(_ context.Context, postID uuid.UUID) error
- func (r *Memory) DeleteComment(_ context.Context, postID, commentID uuid.UUID) error
- func (r *Memory) GetAll(_ context.Context) ([]*post.Post, error)
- func (r *Memory) GetByCatName(_ context.Context, catName string) ([]*post.Post, error)
- func (r *Memory) GetByID(_ context.Context, postID uuid.UUID) (*post.Post, error)
- func (r *Memory) GetByUserID(_ context.Context, userID uuid.UUID) ([]*post.Post, error)
- func (r *Memory) GetCommentByID(_ context.Context, commentID uuid.UUID) (*post.Comment, error)
- func (r *Memory) GetComments(_ context.Context, postID uuid.UUID) ([]*post.Comment, error)
- func (r *Memory) GetVotes(_ context.Context, postID uuid.UUID) ([]*post.Vote, error)
- type PostDB
- type Postgres
- func (r *Postgres) Add(ctx context.Context, newPost post.Post) error
- func (r *Postgres) AddComment(ctx context.Context, newComment post.Comment) error
- func (r *Postgres) AddVote(ctx context.Context, postID uuid.UUID, vote post.Vote) error
- func (r *Postgres) CheckVote(ctx context.Context, postID uuid.UUID, userID uuid.UUID) error
- func (r *Postgres) Count(ctx context.Context) (int, error)
- func (r *Postgres) Delete(ctx context.Context, postID uuid.UUID) error
- func (r *Postgres) DeleteComment(ctx context.Context, commentID uuid.UUID) error
- func (r *Postgres) GetAll(ctx context.Context, pageNum int, rowsPerPage int) ([]post.Post, error)
- func (r *Postgres) GetByCatName(ctx context.Context, catName string) ([]post.Post, error)
- func (r *Postgres) GetByID(ctx context.Context, postID uuid.UUID) (post.Post, error)
- func (r *Postgres) GetByUserID(ctx context.Context, userID uuid.UUID) ([]post.Post, error)
- func (r *Postgres) GetCommentByID(ctx context.Context, commentID uuid.UUID) (post.Comment, error)
- func (r *Postgres) GetCommentsByPostID(ctx context.Context, postID uuid.UUID) ([]post.Comment, error)
- func (r *Postgres) GetCommentsByPostIDs(ctx context.Context, postIDs []uuid.UUID) ([]post.Comment, error)
- func (r *Postgres) GetVotesByPostID(ctx context.Context, postID uuid.UUID) ([]post.Vote, error)
- func (r *Postgres) GetVotesByPostIDs(ctx context.Context, postIDs []uuid.UUID) ([]post.Vote, error)
- func (r *Postgres) UpdateVote(ctx context.Context, postID uuid.UUID, vote post.Vote) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Memory ¶
type Memory struct {
// contains filtered or unexported fields
}
Memory Represents in-memory storage for posts data.
func (*Memory) AddComment ¶
func (r *Memory) AddComment(_ context.Context, postID uuid.UUID, newComment *post.Comment) (commentID uuid.UUID, err error)
AddComment Adds comment to the givven post.
func (*Memory) DeleteComment ¶
DeleteComment Removes comment from storage by post, comment IDs.
func (*Memory) GetByCatName ¶
GetByCatName Finds posts of given category.
func (*Memory) GetByUserID ¶
GetByUserID Finds posts of given user by user ID.
func (*Memory) GetCommentByID ¶
GetCommentByID Finds comment by comment ID.
func (*Memory) GetComments ¶
GetComments Finds comments of the givven post in the app strorage.
type PostDB ¶
type PostDB struct {
// contains filtered or unexported fields
}
PostDB represents single post in the storage.
func (PostDB) CommentsList ¶
CommentsList Returns all comments as list.
type Postgres ¶
type Postgres struct {
// contains filtered or unexported fields
}
Postgres represents postgres storage for posts data.
func (*Postgres) AddComment ¶
AddComment create comment in the app storage.
func (*Postgres) DeleteComment ¶
DeleteComment removes comment from the app storage.
func (*Postgres) GetByCatName ¶
GetByCatName finds posts of given category.
func (*Postgres) GetByUserID ¶
GetByUserID finds posts of given user by user ID.
func (*Postgres) GetCommentByID ¶
GetCommentByID finds comment by it ID.
func (*Postgres) GetCommentsByPostID ¶
func (r *Postgres) GetCommentsByPostID(ctx context.Context, postID uuid.UUID) ([]post.Comment, error)
GetComments returns a list of post comments.
func (*Postgres) GetCommentsByPostIDs ¶
func (r *Postgres) GetCommentsByPostIDs(ctx context.Context, postIDs []uuid.UUID) ([]post.Comment, error)
GetCommentsByPostIDs returns a list of posts comments.
func (*Postgres) GetVotesByPostID ¶
GetVotes returns a list of post votes.
func (*Postgres) GetVotesByPostIDs ¶
GetVotesByPostIDs returns a list of posts votes.