package daconfdbacc

import (
	"context"

	"github.com/kweaver-ai/kweaver-core/decision-agent/agent-backend/agent-factory/src/infra/common/chelper/dbhelper2"
	"github.com/kweaver-ai/kweaver-core/decision-agent/agent-backend/agent-factory/src/infra/persistence/dapo"
)

func (repo *DAConfigRepo) ExistsByName(ctx context.Context, name string) (exists bool, err error) {
	sr := dbhelper2.NewSQLRunner(repo.db, repo.logger)
	sr.FromPo(&dapo.DataAgentPo{})
	exists, err = sr.WhereEqual("f_name", name).
		WhereEqual("f_deleted_at", 0).
		Exists()

	return
}
