postgres

package
v0.0.0-...-7f86f56 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2022 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

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) Create

func (r *PostRepository) Create(ctx context.Context, post domain.Post) error

Creating a new post in postgres database.

func (*PostRepository) Delete

func (r *PostRepository) Delete(ctx context.Context, id, authorId ksuid.KSUID) error

Deleting a post in postgres database.

func (*PostRepository) Get

Getting a post by id in postgres database.

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

func (r *PostRepository) GetTotalCount(ctx context.Context, authorId ksuid.KSUID) (int32, error)

Getting total author posts count in postgres database.

func (*PostRepository) Update

func (r *PostRepository) Update(ctx context.Context, post domain.Post) error

Updating a post 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.

Directories

Path Synopsis
Package mock_postgres is a generated GoMock package.
Package mock_postgres is a generated GoMock package.

Jump to

Keyboard shortcuts

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