uow

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 4 Imported by: 0

README

uow

import "github.com/brpaz/lib-go/db/uow"

Package uow provides a GORM-backed implementation of [libuow.Manager] and [libuow.UnitOfWork].

Use NewManager to create a transaction manager scoped to a set of repositories. Each call to GormManager.Begin opens a new database transaction and returns the repository bundle constructed by the supplied build function.

Index

type GormManager

GormManager is the GORM implementation of [libuow.Manager]. Build is called once per [Begin] with the transaction-scoped *gorm.DB; it should construct all repository instances for that transaction.

type GormManager[T any] struct {
    // contains filtered or unexported fields
}

func NewManager
func NewManager[T any](db *gorm.DB, build func(*gorm.DB) T) (*GormManager[T], error)

NewManager creates a GormManager. build receives a transaction *gorm.DB on each Begin call and must return the module's repository bundle.

func (*GormManager[T]) Begin
func (m *GormManager[T]) Begin(ctx context.Context) (libuow.UnitOfWork[T], error)

Generated by gomarkdoc

Documentation

Overview

Package uow provides a GORM-backed implementation of libuow.Manager and libuow.UnitOfWork.

Use NewManager to create a transaction manager scoped to a set of repositories. Each call to GormManager.Begin opens a new database transaction and returns the repository bundle constructed by the supplied build function.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GormManager

type GormManager[T any] struct {
	// contains filtered or unexported fields
}

GormManager is the GORM implementation of libuow.Manager. Build is called once per [Begin] with the transaction-scoped *gorm.DB; it should construct all repository instances for that transaction.

func NewManager

func NewManager[T any](db *gorm.DB, build func(*gorm.DB) T) (*GormManager[T], error)

NewManager creates a GormManager. build receives a transaction *gorm.DB on each Begin call and must return the module's repository bundle.

func (*GormManager[T]) Begin

func (m *GormManager[T]) Begin(ctx context.Context) (libuow.UnitOfWork[T], error)

Jump to

Keyboard shortcuts

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