repository

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Base repository package

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseRepository

type BaseRepository struct {
	DB *ent.Client
}

BaseRepository provides common database functionality

func NewBaseRepository

func NewBaseRepository(db *ent.Client) *BaseRepository

NewBaseRepository creates a new repository

func (*BaseRepository) WithTx

func (r *BaseRepository) WithTx(ctx context.Context, fn func(tx TxInterface) error) error

WithTx runs a function in a transaction Usage example:

if err := r.WithTx(func(tx *ent.Tx) error {
	 Do stuff with tx
	return nil
}); err != nil {

	 Handle error
}

type BaseRepositoryInterface

type BaseRepositoryInterface interface {
	// WithTx runs a function in a transaction
	// Usage example:
	//
	//	if err := r.WithTx(func(tx *ent.Tx) error {
	//		 Do stuff with tx
	//		return nil
	//	}); err != nil {
	//
	//		 Handle error
	//	}
	WithTx(ctx context.Context, fn func(tx TxInterface) error) error
}

BaseRepositoryInterface ...

type TxInterface

type TxInterface interface {
	Commit() error
	Rollback() error
	Client() *ent.Client
}

Jump to

Keyboard shortcuts

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