orm

package
v1.2.17 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const ExtensionName = "orm"

Variables

This section is empty.

Functions

func NewExtension

func NewExtension() database.Extension[Extended]

NewExtension creates a new extension instance example:

var db database.Database
extension := orm.NewExtension().InitializeExtension(db)

then can use extension to execute gorm function

extension.ExecuteGormFunction(func(db *gorm.DB) *gorm.DB {
	return db.Model(&User{}).Where("id = ?", 1)
})

Types

type Extended

type Extended interface {
	database.Extended
	ExecuteGormFunction(execFunc func(db *gorm.DB) *gorm.DB) error
	QueryGormFunction(receiver any, queryFunc func(db *gorm.DB) *gorm.DB) error
	ExecuteGormTransaction(execFunc func(tx *gorm.DB) error) error
	ExecuteGormFunctionWithCtx(ctx context.Context, execFunc func(db *gorm.DB) *gorm.DB) error
	QueryGormFunctionWithCtx(ctx context.Context, receiver any, queryFunc func(db *gorm.DB) *gorm.DB) error
	ExecuteGormTransactionWithCtx(ctx context.Context, execFunc func(tx *gorm.DB) error) error
}

type Extension

type Extension struct{}

func (*Extension) InitializeExtension

func (e *Extension) InitializeExtension(base database.Database) Extended

Jump to

Keyboard shortcuts

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