package dbutil

// Database access should be done through this file.
import (
	"github.com/tidbcloud/dataflow-service/app/repo/entity"
	"gorm.io/gorm"
)

// GetRestoreByClusterIDWithoutPreloadCluster is get the restore by clusterID without preload cluster
func GetRestoreByClusterIDWithoutPreloadCluster(tx *gorm.DB, clusterID entity.ID) (*entity.Restore, error) {
	var restore entity.Restore
	err := entity.NewRestoreQuerySet(tx).ClusterIDEq(clusterID).OrderDescByCreatedAt().One(&restore)
	if err != nil {
		return &restore, TagNotFound(err)
	}
	return &restore, nil
}
