Skip to content

Instantly share code, notes, and snippets.

@mehmetcemyucel
Created April 28, 2022 14:48
Show Gist options
  • Save mehmetcemyucel/ddc98ffc4f331b87feb3d8fd5a3af202 to your computer and use it in GitHub Desktop.
Save mehmetcemyucel/ddc98ffc4f331b87feb3d8fd5a3af202 to your computer and use it in GitHub Desktop.
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