Repo options
This commit is contained in:
@ -3,7 +3,6 @@ package repository
|
||||
import (
|
||||
"repo-pattern/app/repository/smartfilter"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/schema"
|
||||
)
|
||||
|
||||
@ -13,11 +12,11 @@ type GetOptions struct {
|
||||
}
|
||||
|
||||
type GetMethod[T schema.Tabler] struct {
|
||||
DbConn *gorm.DB
|
||||
repo *RepoBase[T]
|
||||
}
|
||||
|
||||
func (m *GetMethod[T]) Init(dbConn *gorm.DB) {
|
||||
m.DbConn = dbConn
|
||||
func (m *GetMethod[T]) Init(repo *RepoBase[T]) {
|
||||
m.repo = repo
|
||||
}
|
||||
|
||||
func (m GetMethod[T]) Get(filter interface{}, options *GetOptions) (*T, error) {
|
||||
@ -25,7 +24,7 @@ func (m GetMethod[T]) Get(filter interface{}, options *GetOptions) (*T, error) {
|
||||
model T
|
||||
)
|
||||
|
||||
query, err := smartfilter.ToQuery(model, filter, m.DbConn)
|
||||
query, err := smartfilter.ToQuery(model, filter, m.repo.dbConn)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user