Count method

This commit is contained in:
Eden Kirin
2024-06-25 01:52:50 +02:00
parent 4615d55309
commit 3dc8d0d79f
5 changed files with 122 additions and 7 deletions

View File

@ -20,10 +20,11 @@ type RepoBase[T schema.Tabler] struct {
ListMethod[T]
GetMethod[T]
ExistsMethod[T]
CountMethod[T]
methods []MethodInitInterface[T]
}
func (repo *RepoBase[T]) InitMethods(dbConn *gorm.DB) {
func (repo *RepoBase[T]) InitMethods() {
for _, method := range repo.methods {
method.Init(repo)
}
@ -41,6 +42,11 @@ func (m *RepoBase[T]) Init(dbConn *gorm.DB, options *RepoOptions) {
}
}
m.methods = []MethodInitInterface[T]{&m.ListMethod, &m.GetMethod, &m.ExistsMethod}
m.InitMethods(dbConn)
m.methods = []MethodInitInterface[T]{
&m.ListMethod,
&m.GetMethod,
&m.ExistsMethod,
&m.CountMethod,
}
m.InitMethods()
}