func (r *Repository) Find() ([]*domain.Policy, error) {
	policies := []*domain.Policy{}
	var models []*model.Policy
	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
		}
		policies = append(policies, p)
	}
	return policies, nil
}
Find records based on filters
package policy
import (
	"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.Policy) error {
	m := new(model.Policy)
	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
		}
		newPolicy, err := m.ToDomain()
		if err != nil {
			return err
		}
		*p = *newPolicy
		return nil
	})
}