Created
April 28, 2022 14:48
-
-
Save mehmetcemyucel/ddc98ffc4f331b87feb3d8fd5a3af202 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package repository | |
import ( | |
"gorm.io/gorm" | |
"helloWorld/pkg/model/example/entity" | |
) | |
type IExampleRepository interface { | |
ActiveExamples(name string) ([]entity.Example, error) | |
} | |
type ExampleRepository struct { | |
db *gorm.DB | |
} | |
func NewRepository(db *gorm.DB) IExampleRepository { | |
var repo IExampleRepository | |
repo = &ExampleRepository{db} | |
return repo | |
} | |
func (p *ExampleRepository) ActiveExamples(name string) ([]entity.Example, error) { | |
var examples []entity.Example | |
err := p.db.Where(`name = ? and deleted_at is null`, name).Find(&examples).Error | |
return examples, err | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment