mirror of
https://github.com/netbirdio/management-refactor.git
synced 2026-05-22 17:12:59 -07:00
logical context merged module approach
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"management/internal/shared/hook"
|
||||
)
|
||||
|
||||
type Model interface {
|
||||
TableName() string
|
||||
}
|
||||
|
||||
type ModelEvent[T Model] struct {
|
||||
hook.Event
|
||||
|
||||
Tx Transaction
|
||||
Context context.Context
|
||||
Model *T
|
||||
}
|
||||
|
||||
type ModelErrorEvent[T Model] struct {
|
||||
Error error
|
||||
ModelEvent[T]
|
||||
}
|
||||
|
||||
func (e *ModelEvent[T]) Tags() []string {
|
||||
if e.Model == nil {
|
||||
return nil
|
||||
}
|
||||
return []string{(*e.Model).TableName()}
|
||||
}
|
||||
Reference in New Issue
Block a user