callbacks

package
v1.31.2 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2026 License: MIT Imports: 8 Imported by: 668

Documentation

Overview

Package callbacks provides the default callback functions for GORM operations such as create, query, update, and delete.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AfterCreate

func AfterCreate(db *gorm.DB)

AfterCreate after create hooks

func AfterDelete

func AfterDelete(db *gorm.DB)

func AfterQuery

func AfterQuery(db *gorm.DB)

func AfterUpdate

func AfterUpdate(db *gorm.DB)

AfterUpdate after update hooks

func BeforeCreate

func BeforeCreate(db *gorm.DB)

BeforeCreate before create hooks

func BeforeDelete

func BeforeDelete(db *gorm.DB)

func BeforeUpdate

func BeforeUpdate(db *gorm.DB)

BeforeUpdate before update hooks

func BeginTransaction

func BeginTransaction(db *gorm.DB)

func BuildQuerySQL

func BuildQuerySQL(db *gorm.DB)

func CommitOrRollbackTransaction

func CommitOrRollbackTransaction(db *gorm.DB)

func ConvertMapToValuesForCreate

func ConvertMapToValuesForCreate(stmt *gorm.Statement, mapValue map[string]interface{}) (values clause.Values)

ConvertMapToValuesForCreate convert map to values

func ConvertSliceOfMapToValuesForCreate

func ConvertSliceOfMapToValuesForCreate(stmt *gorm.Statement, mapValues []map[string]interface{}) (values clause.Values)

ConvertSliceOfMapToValuesForCreate convert slice of map to values

func ConvertToAssignments

func ConvertToAssignments(stmt *gorm.Statement) (set clause.Set)

ConvertToAssignments convert to update assignments

func ConvertToCreateValues

func ConvertToCreateValues(stmt *gorm.Statement) (values clause.Values)

ConvertToCreateValues convert to create values

func Create

func Create(config *Config) func(db *gorm.DB)

Create create hook

func Delete

func Delete(config *Config) func(db *gorm.DB)

func DeleteBeforeAssociations added in v1.20.1

func DeleteBeforeAssociations(db *gorm.DB)

func Preload

func Preload(db *gorm.DB)

func Query

func Query(db *gorm.DB)

func RawExec

func RawExec(db *gorm.DB)

func RegisterDefaultCallbacks

func RegisterDefaultCallbacks(db *gorm.DB, config *Config)

func RowQuery

func RowQuery(db *gorm.DB)

func SaveAfterAssociations

func SaveAfterAssociations(create bool) func(db *gorm.DB)

func SaveBeforeAssociations

func SaveBeforeAssociations(create bool) func(db *gorm.DB)

func SetupUpdateReflectValue

func SetupUpdateReflectValue(db *gorm.DB)

func Update

func Update(config *Config) func(db *gorm.DB)

Update update hook

Types

type AfterCreateInterface added in v0.2.38

type AfterCreateInterface interface {
	AfterCreate(*gorm.DB) error
}

type AfterDeleteInterface added in v0.2.38

type AfterDeleteInterface interface {
	AfterDelete(*gorm.DB) error
}

type AfterFindInterface added in v0.2.38

type AfterFindInterface interface {
	AfterFind(*gorm.DB) error
}

type AfterSaveInterface added in v0.2.38

type AfterSaveInterface interface {
	AfterSave(*gorm.DB) error
}

type AfterUpdateInterface added in v0.2.38

type AfterUpdateInterface interface {
	AfterUpdate(*gorm.DB) error
}

type BeforeCreateInterface added in v0.2.38

type BeforeCreateInterface interface {
	BeforeCreate(*gorm.DB) error
}

type BeforeDeleteInterface added in v0.2.38

type BeforeDeleteInterface interface {
	BeforeDelete(*gorm.DB) error
}

type BeforeSaveInterface added in v0.2.38

type BeforeSaveInterface interface {
	BeforeSave(*gorm.DB) error
}

type BeforeUpdateInterface added in v0.2.38

type BeforeUpdateInterface interface {
	BeforeUpdate(*gorm.DB) error
}

type Config

type Config struct {
	LastInsertIDReversed bool
	CreateClauses        []string
	QueryClauses         []string
	UpdateClauses        []string
	DeleteClauses        []string
}

Jump to

Keyboard shortcuts

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