- Sort Score
- Result 10 results
- Languages All
Results 1 - 7 of 7 for callMethod (0.18 sec)
-
callbacks/callmethod.go
package callbacks import ( "reflect" "gorm.io/gorm" ) func callMethod(db *gorm.DB, fc func(value interface{}, tx *gorm.DB) bool) { tx := db.Session(&gorm.Session{NewDB: true}) if called := fc(db.Statement.ReflectValue.Interface(), tx); !called { switch db.Statement.ReflectValue.Kind() { case reflect.Slice, reflect.Array: db.Statement.CurDestIndex = 0 for i := 0; i < db.Statement.ReflectValue.Len(); i++ {
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Sat Feb 18 01:20:29 UTC 2023 - 846 bytes - Viewed (0) -
tests/callbacks_test.go
} if c.before != "" { callMethod(v, "Before", c.before) } if c.after != "" { callMethod(v, "After", c.after) } if c.match != nil { callMethod(v, "Match", c.match) } if c.remove { callMethod(v, "Remove", c.name) } else if c.replace { callMethod(v, "Replace", c.name, c.h) } else { callMethod(v, "Register", c.name, c.h) }
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Tue Mar 26 03:33:36 UTC 2024 - 7.2K bytes - Viewed (0) -
callbacks/update.go
} // BeforeUpdate before update hooks func BeforeUpdate(db *gorm.DB) { if db.Error == nil && db.Statement.Schema != nil && !db.Statement.SkipHooks && (db.Statement.Schema.BeforeSave || db.Statement.Schema.BeforeUpdate) { callMethod(db, func(value interface{}, tx *gorm.DB) (called bool) { if db.Statement.Schema.BeforeSave { if i, ok := value.(BeforeSaveInterface); ok { called = true db.AddError(i.BeforeSave(tx)) } }
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Mon Mar 18 05:44:55 UTC 2024 - 9.4K bytes - Viewed (0) -
callbacks/delete.go
"gorm.io/gorm/schema" "gorm.io/gorm/utils" ) func BeforeDelete(db *gorm.DB) { if db.Error == nil && db.Statement.Schema != nil && !db.Statement.SkipHooks && db.Statement.Schema.BeforeDelete { callMethod(db, func(value interface{}, tx *gorm.DB) bool { if i, ok := value.(BeforeDeleteInterface); ok { db.AddError(i.BeforeDelete(tx)) return true } return false }) } }
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Fri Feb 25 02:48:23 UTC 2022 - 5.6K bytes - Viewed (0) -
callbacks/create.go
) // BeforeCreate before create hooks func BeforeCreate(db *gorm.DB) { if db.Error == nil && db.Statement.Schema != nil && !db.Statement.SkipHooks && (db.Statement.Schema.BeforeSave || db.Statement.Schema.BeforeCreate) { callMethod(db, func(value interface{}, tx *gorm.DB) (called bool) { if db.Statement.Schema.BeforeSave { if i, ok := value.(BeforeSaveInterface); ok { called = true db.AddError(i.BeforeSave(tx)) } }
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Mon Apr 08 03:29:55 UTC 2024 - 12.5K bytes - Viewed (0) -
callbacks/query.go
db.Statement.Clauses["FROM"] = fromClause } if db.Error == nil && db.Statement.Schema != nil && !db.Statement.SkipHooks && db.Statement.Schema.AfterFind && db.RowsAffected > 0 { callMethod(db, func(value interface{}, tx *gorm.DB) bool { if i, ok := value.(AfterFindInterface); ok { db.AddError(i.AfterFind(tx)) return true } return false }) }
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Thu Aug 22 11:03:42 UTC 2024 - 10.1K bytes - Viewed (1) -
tests/transaction_test.go
return tx2.Scan(&User{}).Error }) }) if err != nil { t.Error(err) } // method with hooks err = DB.Transaction(func(tx1 *gorm.DB) error { // callMethod do tx2 := tx1.Find(&User{}).Session(&gorm.Session{NewDB: true}) // trx in hooks return tx2.Transaction(func(tx3 *gorm.DB) error { return tx3.Where("user_id", user.ID).Delete(&Account{}).Error }) })
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Sat Sep 14 12:58:29 UTC 2024 - 12.9K bytes - Viewed (0)