Documentation
¶
Overview ¶
Example of basic repository implementation
Example of integration with dependency injection ¶
Example of using repository factory
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DIInMemoryUserRepository ¶
type DIInMemoryUserRepository struct {
// contains filtered or unexported fields
}
DIInMemoryUserRepository implements the Repository interface for DIUser entities
func NewDIInMemoryUserRepository ¶
func NewDIInMemoryUserRepository() *DIInMemoryUserRepository
NewDIInMemoryUserRepository creates a new in-memory user repository
func (*DIInMemoryUserRepository) GetAll ¶
func (r *DIInMemoryUserRepository) GetAll(ctx context.Context) ([]DIUser, error)
GetAll retrieves all users
type FactoryInMemoryUserRepository ¶
type FactoryInMemoryUserRepository struct {
// contains filtered or unexported fields
}
FactoryInMemoryUserRepository implements the Repository interface for FactoryUser entities
func NewFactoryInMemoryUserRepository ¶
func NewFactoryInMemoryUserRepository() *FactoryInMemoryUserRepository
NewFactoryInMemoryUserRepository creates a new in-memory user repository
func (*FactoryInMemoryUserRepository) GetAll ¶
func (r *FactoryInMemoryUserRepository) GetAll(ctx context.Context) ([]FactoryUser, error)
GetAll retrieves all users
func (*FactoryInMemoryUserRepository) GetByID ¶
func (r *FactoryInMemoryUserRepository) GetByID(ctx context.Context, id string) (FactoryUser, error)
GetByID retrieves a user by ID
func (*FactoryInMemoryUserRepository) Save ¶
func (r *FactoryInMemoryUserRepository) Save(ctx context.Context, user FactoryUser) error
Save persists a user
type FactoryUser ¶
FactoryUser is a domain entity
type InMemoryOrderRepository ¶
type InMemoryOrderRepository struct {
// contains filtered or unexported fields
}
InMemoryOrderRepository implements the Repository interface for Order entities
func NewInMemoryOrderRepository ¶
func NewInMemoryOrderRepository() *InMemoryOrderRepository
NewInMemoryOrderRepository creates a new in-memory order repository
func (*InMemoryOrderRepository) GetAll ¶
func (r *InMemoryOrderRepository) GetAll(ctx context.Context) ([]Order, error)
GetAll retrieves all orders
type InMemoryUserRepository ¶
type InMemoryUserRepository struct {
// contains filtered or unexported fields
}
InMemoryUserRepository implements the Repository interface for User entities
func NewInMemoryUserRepository ¶
func NewInMemoryUserRepository() *InMemoryUserRepository
NewInMemoryUserRepository creates a new in-memory user repository
func (*InMemoryUserRepository) GetAll ¶
func (r *InMemoryUserRepository) GetAll(ctx context.Context) ([]User, error)
GetAll retrieves all users
type RepositoryFactoryImpl ¶
type RepositoryFactoryImpl struct {
// contains filtered or unexported fields
}
RepositoryFactoryImpl implements the RepositoryFactory interface
func NewRepositoryFactory ¶
func NewRepositoryFactory( userRepo repository.Repository[FactoryUser], orderRepo repository.Repository[Order], ) *RepositoryFactoryImpl
NewRepositoryFactory creates a new repository factory
func (*RepositoryFactoryImpl) GetOrderRepository ¶
func (f *RepositoryFactoryImpl) GetOrderRepository() repository.Repository[Order]
GetOrderRepository returns the order repository
func (*RepositoryFactoryImpl) GetRepository ¶
func (f *RepositoryFactoryImpl) GetRepository() any
GetRepository returns a repository for the given entity type
func (*RepositoryFactoryImpl) GetUserRepository ¶
func (f *RepositoryFactoryImpl) GetUserRepository() repository.Repository[FactoryUser]
GetUserRepository returns the user repository
type UserService ¶
type UserService struct {
// contains filtered or unexported fields
}
UserService is a domain service that uses a repository
func NewUserService ¶
func NewUserService(userRepo repository.Repository[DIUser]) *UserService
NewUserService creates a new user service
func (*UserService) CreateUser ¶
CreateUser creates a new user