Documentation
¶
Index ¶
- type Post
- type PostRepository
- func (r *PostRepository) Create(ctx context.Context, post domain.Post) error
- func (r *PostRepository) Delete(ctx context.Context, id, authorId ksuid.KSUID) error
- func (r *PostRepository) Get(ctx context.Context, id ksuid.KSUID) (domain.Post, error)
- func (r *PostRepository) GetPosts(ctx context.Context, authorId ksuid.KSUID, sort domain.SortOptions) ([]domain.Post, error)
- func (r *PostRepository) GetTotalCount(ctx context.Context, authorId ksuid.KSUID) (int32, error)
- func (r *PostRepository) Update(ctx context.Context, post domain.Post) error
- type PostgresRepository
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Post ¶
type Post interface {
// Creating a new post in postgres database.
Create(ctx context.Context, post domain.Post) error
// Getting a post by id in postgres database.
Get(ctx context.Context, id ksuid.KSUID) (domain.Post, error)
// Getting author posts by author id in postgres database.
GetPosts(ctx context.Context, authorId ksuid.KSUID, sort domain.SortOptions) ([]domain.Post, error)
// Deleting a post in postgres database.
Delete(ctx context.Context, id, authorId ksuid.KSUID) error
// Updating a post in postgres database.
Update(ctx context.Context, post domain.Post) error
// Getting total author posts count in postgres database.
GetTotalCount(ctx context.Context, authorId ksuid.KSUID) (int32, error)
}
Post repository interface.
type PostRepository ¶
type PostRepository struct {
// contains filtered or unexported fields
}
Post repository structure.
func NewPostRepository ¶
func NewPostRepository(psql postgres.Postgres) *PostRepository
Creating a new post repository.
func (*PostRepository) GetPosts ¶
func (r *PostRepository) GetPosts(ctx context.Context, authorId ksuid.KSUID, sort domain.SortOptions) ([]domain.Post, error)
Getting author posts by author id in postgres database.
func (*PostRepository) GetTotalCount ¶
Getting total author posts count in postgres database.
type PostgresRepository ¶
type PostgresRepository struct{ Post }
Postgres repository structure.
func NewPostgresRepository ¶
func NewPostgresRepository(cfg config.PostgresConfig) *PostgresRepository
Creating a new postgres repository.
Click to show internal directories.
Click to hide internal directories.