func (r *Repository) GetByID(id uint) (*domain.Provider, error) {
	if id == 0 {
		return nil, ErrEmptyIDParam
	}
	var m model.Provider
	if err := r.db.First(&m, "id = ?", id).Error; err != nil {
		if err == gorm.ErrRecordNotFound {
			return nil, ErrRecordNotFound
		}
		return nil, err
	}
	p, err := m.ToDomain()
	if err != nil {
		return nil, err
	}
	return p, nil
}
GetByID record by ID
package provider
import (
	"errors"
	"github.com/odpf/guardian/domain"
	"github.com/odpf/guardian/model"
	"gorm.io/gorm"
)
type Repository struct {
	db *gorm.DB
}
func NewRepository(db *gorm.DB) *Repository {
	return &Repository{db}
}
func (r *Repository) Create(p *domain.Provider) error {
	m := new(model.Provider)
	if err := m.FromDomain(p); err != nil {
		return err
	}
	return r.db.Transaction(func(tx *gorm.DB) error {
		if result := tx.Create(m); result.Error != nil {
			return result.Error
		}
		newProvider, err := m.ToDomain()
		if err != nil {
			return err
		}
		*p = *newProvider
		return nil
	})
}
func (r *Repository) Find() ([]*domain.Provider, error) {
	providers := []*domain.Provider{}
	var models []*model.Provider
	if err := r.db.Find(&models).Error; err != nil {
		return nil, err
	}
	for _, m := range models {
		p, err := m.ToDomain()
		if err != nil {
			return nil, err
		}
		providers = append(providers, p)
	}
	return providers, nil
}