Skip to content

Instantly share code, notes, and snippets.

@percybolmer
Created August 30, 2021 06:28
Show Gist options
  • Save percybolmer/c636f33d69722ee64382e4eabb8dd143 to your computer and use it in GitHub Desktop.
Save percybolmer/c636f33d69722ee64382e4eabb8dd143 to your computer and use it in GitHub Desktop.
// Package product holds the repository and the implementations for a ProductRepository
package product
import (
"errors"
"github.com/google/uuid"
"github.com/percybolmer/ddd-go/aggregate"
)
var (
//ErrProductNotFound is returned when a product is not found
ErrProductNotFound = errors.New("the product was not found")
//ErrProductAlreadyExist is returned when trying to add a product that already exists
ErrProductAlreadyExist = errors.New("the product already exists")
)
// ProductRepository is the repository interface to fulfill to use the product aggregate
type ProductRepository interface {
GetAll() ([]aggregate.Product, error)
GetByID(id uuid.UUID) (aggregate.Product, error)
Add(product aggregate.Product) error
Update(product aggregate.Product) error
Delete(id uuid.UUID) error
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment