Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type UnitOfWork ¶
type UnitOfWork interface {
// Do executes a function within a database transaction.
// If the function returns an error, the transaction is rolled back.
// If the function succeeds, the transaction is committed.
Do(ctx context.Context, fn func(txUow UnitOfWork) error) error
// UserRepository returns the user repository for this unit of work.
// If called within a transaction, it returns a transactional repository.
UserRepository() repository.UserRepository
}
UnitOfWork defines the interface for a unit of work pattern. It manages database transactions and provides access to repositories within the transaction boundary.
func NewUnitOfWork ¶
func NewUnitOfWork(client *ent.Client) UnitOfWork
NewUnitOfWork creates a new UnitOfWork instance.
Click to show internal directories.
Click to hide internal directories.