repository

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package repository provides abstractions and implementations for data persistence.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TaskRepository

type TaskRepository interface {
	// Create persists a new task in the chosen data store.
	Create(task domain.Task) (domain.Task, error)
	// List retrieves all available tasks from the data store.
	List() ([]domain.Task, error)
	// GetByID finds a single task by its unique identifier.
	GetByID(id int) (domain.Task, error)
	// Update modifies an existing task identified by its ID.
	Update(id int, task domain.Task) (domain.Task, error)
	// Delete removes a task from the data store by its ID.
	Delete(id int) error
}

TaskRepository defines the interface for task data access and persistence operations. It follows the Dependency Inversion principle, allowing the handlers to remain agnostic of the underlying database technology.

func NewMemoryRepository

func NewMemoryRepository() TaskRepository

NewMemoryRepository creates a new in-memory task repository.

func NewPostgresRepository

func NewPostgresRepository(db *sql.DB) TaskRepository

NewPostgresRepository creates a new PostgreSQL task repository.

Jump to

Keyboard shortcuts

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