unitofwork

package
v0.0.0-...-21c6822 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2025 License: MIT Imports: 5 Imported by: 0

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL