Documentation ¶
Index ¶
- Variables
- type Application
- func (app *Application) CreateEntity(ctx context.Context, entity *domain.Entity) (*domain.Entity, error)
- func (app *Application) GetEntityById(ctx context.Context, entityId string) (*domain.Entity, error)
- func (app *Application) GetEntityByName(ctx context.Context, entityId string) (*domain.Entity, error)
- func (app *Application) IsZero() bool
- func (app *Application) ValidateRecord(ctx context.Context, entity *domain.Entity, record *domain.Record) ([]*domain.RecordValidationError, error)
- type EntityRepository
Constants ¶
This section is empty.
Variables ¶
var ErrNoEntitiesFound = errors.New("no entities found")
ErrNoEntitiesFound occurs when fetching entities in the repositoty none was returned. This is mainly used to decouple the error from any type of repository
Functions ¶
This section is empty.
Types ¶
type Application ¶
type Application struct {
// contains filtered or unexported fields
}
Application glues different layers of the service in order to perform actions
func NewApplication ¶
func NewApplication( entityRepository EntityRepository, ) (*Application, error)
NewApplication creates an instance of Application
func (*Application) CreateEntity ¶
func (app *Application) CreateEntity(ctx context.Context, entity *domain.Entity) (*domain.Entity, error)
CreateEntity creates an entity with fields and rules
func (*Application) GetEntityById ¶
GetEntityById returns an entity related to its id
func (*Application) GetEntityByName ¶
func (app *Application) GetEntityByName(ctx context.Context, entityId string) (*domain.Entity, error)
GetEntityByName returns an entity related to its name
func (*Application) IsZero ¶
func (app *Application) IsZero() bool
IsZero defines if the entity application is empty
func (*Application) ValidateRecord ¶
func (app *Application) ValidateRecord( ctx context.Context, entity *domain.Entity, record *domain.Record, ) ([]*domain.RecordValidationError, error)
ValidateRecord will evaluate if each value from the record is valid according to the its field. Rules are defined inside the related entity
type EntityRepository ¶
type EntityRepository interface { // GetEntityById returns one single entity defined by its id GetEntityById(context.Context, string) (*domain.Entity, error) // GetEntityByName returns one single entity defined by its name GetEntityByName(context.Context, string) (*domain.Entity, error) // CreateEntity creates an entity with fields and rules CreateEntity(context.Context, *domain.Entity) (*domain.Entity, error) }
EntityRepository defines the repository that stores, modifies and deletes entities in a store or db