Documentation
¶
Index ¶
- type DocumentModel
- type Repository
- func (r *Repository[T]) Delete(ctx context.Context, id string) error
- func (r *Repository[T]) Get(ctx context.Context, id string) (*DocumentModel[T], error)
- func (r *Repository[T]) List(ctx context.Context) ([]*DocumentModel[T], error)
- func (r *Repository[T]) Save(ctx context.Context, doc *DocumentModel[T]) error
- func (r *Repository[T]) Watch(ctx context.Context, pattern string) (<-chan core.Event, error)
- type Saver
- type Service
- func (s *Service[T]) Delete(ctx context.Context, id string) error
- func (s *Service[T]) Get(ctx context.Context, id string) (*DocumentModel[T], error)
- func (s *Service[T]) List(ctx context.Context) ([]*DocumentModel[T], error)
- func (s *Service[T]) Save(ctx context.Context, doc *DocumentModel[T]) error
- func (s *Service[T]) Watch(ctx context.Context, pattern string) (<-chan core.Event, error)
- func (s *Service[T]) WithTransaction(ctx context.Context, fn func(tx *Transaction[T]) error) error
- type Transaction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DocumentModel ¶
type DocumentModel[T any] struct { ID string Content string Data T // The typed metadata/entities Saver Saver[T] // Active Record reference interface }
DocumentModel wraps the raw core.Document with a typed Metadata field. It acts as a typed view of a document.
type Repository ¶
type Repository[T any] struct { // contains filtered or unexported fields }
Repository wraps a core.Repository to provide type-safe access.
func NewRepository ¶
func NewRepository[T any](repo core.Repository) *Repository[T]
NewRepository creates a new type-safe wrapper around an existing repository.
func (*Repository[T]) Delete ¶
func (r *Repository[T]) Delete(ctx context.Context, id string) error
Delete removes a document by ID.
func (*Repository[T]) Get ¶
func (r *Repository[T]) Get(ctx context.Context, id string) (*DocumentModel[T], error)
Get retrieves a document and unmarshals it.
func (*Repository[T]) List ¶
func (r *Repository[T]) List(ctx context.Context) ([]*DocumentModel[T], error)
List returns all documents converted to the typed model.
func (*Repository[T]) Save ¶
func (r *Repository[T]) Save(ctx context.Context, doc *DocumentModel[T]) error
Save persists a typed document.
type Saver ¶
type Saver[T any] interface { Save(ctx context.Context, doc *DocumentModel[T]) error }
Saver interface avoids circular dependencies or tight coupling with Repository/Service structs.
type Service ¶
type Service[T any] struct { // contains filtered or unexported fields }
Service wraps a core.Service to provide type-safe access and business logic support.
func NewService ¶
NewService creates a new typed service wrapper.
func (*Service[T]) List ¶
func (s *Service[T]) List(ctx context.Context) ([]*DocumentModel[T], error)
List retrieves all documents via Service.
func (*Service[T]) Save ¶
func (s *Service[T]) Save(ctx context.Context, doc *DocumentModel[T]) error
Save persists a typed document using the core Service (including validation/transactions).
func (*Service[T]) WithTransaction ¶
WithTransaction executes a typed function within a transaction.
type Transaction ¶
type Transaction[T any] struct { // contains filtered or unexported fields }
Transaction wraps a core.Transaction for typed operations.
func (*Transaction[T]) Delete ¶
func (t *Transaction[T]) Delete(ctx context.Context, id string) error
Delete removes a document within the transaction.
func (*Transaction[T]) Get ¶
func (t *Transaction[T]) Get(ctx context.Context, id string) (*DocumentModel[T], error)
Get retrieves a document within the transaction.
func (*Transaction[T]) Save ¶
func (t *Transaction[T]) Save(ctx context.Context, doc *DocumentModel[T]) error
Save persists a typed document within the transaction.