Files
GoMembership/internal/repositories/consents_repository.go
$(pass /github/name) 6ac5491053 switched to gorm..
2024-07-10 14:22:56 +02:00

28 lines
519 B
Go

package repositories
import (
"GoMembership/internal/models"
"gorm.io/gorm"
)
type ConsentRepository interface {
CreateConsent(consent *models.Consent) (int64, error)
}
type consentRepository struct {
db *gorm.DB
}
func NewConsentRepository(db *gorm.DB) ConsentRepository {
return &consentRepository{db}
}
func (repo *consentRepository) CreateConsent(consent *models.Consent) (int64, error) {
result := repo.db.Create(consent)
if result.Error != nil {
return 0, result.Error
}
return consent.ID, nil
}