gorm

package
v0.0.0-...-dd0ea4f Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package gorm provides a way to integrate multiple different versions of gorm / potentially other databases go-atomic if they implement the GormlikeDB interface. This can be achieved by embedding the gorm.DB object in a struct which then implements the GormlikeDB interface. As remote either the [generic.GormRemote] can be used or a custom interface definition which is a subset of the methods offered by gorm.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Executer

type Executer[T GormlikeDB[Remote], Remote any] struct {
	// contains filtered or unexported fields
}

Executer implements the [generic.Executer] interface for a sqlx db

func NewExecuter

func NewExecuter[T GormlikeDB[Remote], Remote any](
	db T,
	opts ...ExecuterOption[T, Remote],
) Executer[T, Remote]

NewExecuter creates a new Executer

func (Executer[T, Remote]) Execute

func (executer Executer[T, Remote]) Execute(_ context.Context, run func(Remote) error) error

Execute executes the provided function in a transaction

type ExecuterOption

type ExecuterOption[T GormlikeDB[Remote], Remote any] func(*Executer[T, Remote])

ExecuterOption configures the Executer instance

func WithTxOptions

func WithTxOptions[T GormlikeDB[Remote], Remote any](
	opts *sql.TxOptions,
) ExecuterOption[T, Remote]

WithTxOptions allows setting the TxOptions to use when opening a new transaction

type GormlikeDB

type GormlikeDB[Remote any] interface {
	Begin(...*sql.TxOptions) GormlikeDB[Remote]
	Rollback() GormlikeDB[Remote]
	Commit() GormlikeDB[Remote]
	Remote() Remote
	Error() error
}

GormlikeDB is an interface that allows different versions of gorm or other similar db's to be used as executer for [generic.Transacter].

Jump to

Keyboard shortcuts

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