refactor: unify tags and edges into single rels table

This commit is contained in:
2026-04-01 12:50:45 +02:00
parent 27c72db042
commit 6288879468
9 changed files with 296 additions and 249 deletions

View File

@@ -3,14 +3,24 @@ package cmd
import (
"axolotl/models"
"axolotl/service"
"fmt"
"strings"
)
// parseRelInput parses a "type:target" string into a RelInput.
// parseRelInput parses a rel string into a RelInput.
//
// Formats:
// - "prefix::value" → property rel with no target (tag)
// - "relname:target" → edge rel with a target node
// - "tagname" → simple label rel with no target (alias for --tag)
func parseRelInput(s string) (service.RelInput, error) {
if p := strings.SplitN(s, ":", 2); len(p) == 2 {
return service.RelInput{Type: models.RelType(p[0]), Target: p[1]}, nil
if strings.Contains(s, "::") {
// Property: name::value — no target node.
return service.RelInput{Type: models.RelType(s), Target: ""}, nil
}
return service.RelInput{}, fmt.Errorf("invalid relation format: %s (expected type:target)", s)
if idx := strings.Index(s, ":"); idx >= 0 {
// Edge rel: relname:target.
return service.RelInput{Type: models.RelType(s[:idx]), Target: s[idx+1:]}, nil
}
// Simple label tag — no target node.
return service.RelInput{Type: models.RelType(s), Target: ""}, nil
}