Documentation
¶
Overview ¶
Package services is the framework-agnostic API surface for the blog. All business logic lives here; HTTP handlers (and gRPC/GraphQL/cron jobs) just call these methods.
Index ¶
- type PostService
- func (s *PostService) Comments(ctx context.Context, postID uint64) ([]models.Comment, error)
- func (s *PostService) Create(ctx context.Context, p *models.Post) error
- func (s *PostService) Delete(ctx context.Context, p *models.Post) error
- func (s *PostService) Get(ctx context.Context, id uint64) (*models.Post, error)
- func (s *PostService) IncrementViews(ctx context.Context, id uint64) error
- func (s *PostService) ListWithAuthor(ctx context.Context, limit int) ([]models.Post, map[uint64]*models.User, error)
- func (s *PostService) Pin(ctx context.Context, p *models.Post) error
- func (s *PostService) Unpin(ctx context.Context, p *models.Post) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PostService ¶
type PostService struct {
Conn *database.Connection
}
func NewPostService ¶
func NewPostService(conn *database.Connection) *PostService
func (*PostService) IncrementViews ¶
func (s *PostService) IncrementViews(ctx context.Context, id uint64) error
IncrementViews atomically bumps the views counter. Demonstrates a raw builder UPDATE without round-tripping through the ORM Save path.
func (*PostService) ListWithAuthor ¶
func (s *PostService) ListWithAuthor(ctx context.Context, limit int) ([]models.Post, map[uint64]*models.User, error)
ListWithAuthor returns posts ordered by recency. Each post is enriched with its author via eager-loading — a single extra query instead of N.
Click to show internal directories.
Click to hide internal directories.