switched to gorm..
This commit is contained in:
27
internal/repositories/subscription_model_repository.go
Normal file
27
internal/repositories/subscription_model_repository.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package repositories
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
|
||||
"GoMembership/internal/models"
|
||||
)
|
||||
|
||||
type SubscriptionModelsRepository interface {
|
||||
CreateSubscriptionModel(subscriptionModel *models.SubscriptionModel) (int64, error)
|
||||
}
|
||||
|
||||
type subscriptionModelsRepository struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewSubscriptionModelsRepository(db *gorm.DB) SubscriptionModelsRepository {
|
||||
return &subscriptionModelsRepository{db}
|
||||
}
|
||||
|
||||
func (repo *subscriptionModelsRepository) CreateSubscriptionModel(subscriptionModel *models.SubscriptionModel) (int64, error) {
|
||||
result := repo.db.Create(subscriptionModel)
|
||||
if result.Error != nil {
|
||||
return 0, result.Error
|
||||
}
|
||||
return subscriptionModel.ID, nil
|
||||
}
|
||||
Reference in New Issue
Block a user