type Model interface {
comparable
TableName() (schema, table string)
}
type Change[T Model] struct {
New T
Old T
}
type ModelHandlerFunc[T Model] func(change T) error
type ModelHandlers[T Model] map[T]ModelHandlerFunc[T]
func Consume[T Model](mh ModelHandlers[T]) error {
return nil
}
type Comment struct {
ID string
}
func (c *Comment) TableName() (string, string) {
return "public", "comments"
}
func main() {
c := Comment{}
Consume(map[*Comment]ModelHandlerFunc[*Comment]{
&c: func(change *Comment) error {
return nil
},
})
}
Last active
August 9, 2023 04:05
-
-
Save Yapcheekian/467c4eb610bedf57f071ebfa17f3515a to your computer and use it in GitHub Desktop.
generic.md
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment