package subscriberepository

import (
	"errors"
	"fmt"
	"legalgo-BE-go/database"

	"gorm.io/gorm"
)

func (s *SubsAccs) GetByID(id string) (database.Subscribe, error) {
	var subscribe database.Subscribe

	if err := s.DB.First(&subscribe, "id = ?", id).Error; err != nil {
		if errors.Is(err, gorm.ErrRecordNotFound) {
			return subscribe, fmt.Errorf("subscribe data not found: %v", err)
		}

		return subscribe, err
	}

	return subscribe, nil
}
