postRepo

package
v0.0.0-...-f22daec Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PersistenceDB

type PersistenceDB interface {
	CreatePost(ctx context.Context, post models.Post) (string, error)
	DeletePost(ctx context.Context, id string) error
	GetPosts(ctx context.Context, ids []string) ([]models.Post, error)
	CreateComment(ctx context.Context, comment models.Comment) (string, error)
	CreateLike(ctx context.Context, like models.Like) error
	DeleteComment(ctx context.Context, id string) error
	DeleteLike(ctx context.Context, post_id string, userId string) error
	GetComments(ctx context.Context, id string) ([]models.Comment, error)
	GetLikes(ctx context.Context, id string) ([]models.Like, error)
	GetCounters(ctx context.Context, ids []string) ([]models.CachedCounter, error)
	UpdateCounters(ctx context.Context, counters []models.CachedCounter) error
	Close()
}

type PostgresRepo

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

func NewPostgresRepo

func NewPostgresRepo(primaryDB, replicaDB *sql.DB) *PostgresRepo

func (*PostgresRepo) Close

func (ps *PostgresRepo) Close()

func (*PostgresRepo) CreateComment

func (ps *PostgresRepo) CreateComment(ctx context.Context, comment models.Comment) (string, error)

func (*PostgresRepo) CreateLike

func (ps *PostgresRepo) CreateLike(ctx context.Context, like models.Like) error

func (*PostgresRepo) CreatePost

func (ps *PostgresRepo) CreatePost(ctx context.Context, post models.Post) (string, error)

Write operations use primaryDB

func (*PostgresRepo) DeleteComment

func (ps *PostgresRepo) DeleteComment(ctx context.Context, id string) error

func (*PostgresRepo) DeleteLike

func (ps *PostgresRepo) DeleteLike(ctx context.Context, post_id string, userId string) error

func (*PostgresRepo) DeletePost

func (ps *PostgresRepo) DeletePost(ctx context.Context, id string) error

func (*PostgresRepo) GetComments

func (ps *PostgresRepo) GetComments(ctx context.Context, id string) ([]models.Comment, error)

func (*PostgresRepo) GetCounters

func (ps *PostgresRepo) GetCounters(ctx context.Context, ids []string) ([]models.CachedCounter, error)

func (*PostgresRepo) GetLikes

func (ps *PostgresRepo) GetLikes(ctx context.Context, id string) ([]models.Like, error)

func (*PostgresRepo) GetPosts

func (ps *PostgresRepo) GetPosts(ctx context.Context, ids []string) ([]models.Post, error)

Read operations use replicaDB

func (*PostgresRepo) UpdateCounters

func (ps *PostgresRepo) UpdateCounters(ctx context.Context, counters []models.CachedCounter) error

Write operation - uses primaryDB

Jump to

Keyboard shortcuts

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