Documentation
¶
Overview ¶
Package helpers provides utility functions for transforming and processing Neo4j schema data. It includes functions for converting raw query results from both APOC and native Cypher queries into a standardized, structured format.
Index ¶
- func ConvertToStringSlice(slice []any) []string
- func ConvertValue(value any) any
- func GetStringValue(val any) string
- func MapToAPOCSchema(schemaMap map[string]any) (*types.APOCSchemaResult, error)
- func ProcessAPOCSchema(apocSchema *types.APOCSchemaResult) ([]types.NodeLabel, []types.Relationship, *types.Statistics)
- func ProcessNonAPOCSchema(nodeCounts map[string]int64, ...) ([]types.NodeLabel, []types.Relationship, *types.Statistics)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertToStringSlice ¶
ConvertToStringSlice converts a slice of any type to a slice of strings. It uses fmt.Sprintf to perform the conversion for each element. Example:
input: []any{"user", 123, true}
output: []string{"user", "123", "true"}
func ConvertValue ¶ added in v0.15.0
ConvertValue converts Neo4j value to JSON-compatible value.
func GetStringValue ¶
GetStringValue safely converts any value to its string representation. If the input value is nil, it returns an empty string.
func MapToAPOCSchema ¶
func MapToAPOCSchema(schemaMap map[string]any) (*types.APOCSchemaResult, error)
MapToAPOCSchema converts a raw map from a Cypher query into a structured APOCSchemaResult. This is a workaround for database drivers that may return complex nested structures as `map[string]any` instead of unmarshalling directly into a struct. It achieves this by marshalling the map to YAML and then unmarshalling into the target struct.
func ProcessAPOCSchema ¶
func ProcessAPOCSchema(apocSchema *types.APOCSchemaResult) ([]types.NodeLabel, []types.Relationship, *types.Statistics)
ProcessAPOCSchema transforms the nested result from the `apoc.meta.schema()` procedure into flat lists of node labels and relationships, along with aggregated database statistics. It iterates through entities, processes nodes, and extracts outgoing relationship information nested within those nodes.
func ProcessNonAPOCSchema ¶
func ProcessNonAPOCSchema( nodeCounts map[string]int64, nodePropsMap map[string]map[string]map[string]bool, relCounts map[string]int64, relPropsMap map[string]map[string]map[string]bool, relConnectivity map[string]types.RelConnectivityInfo, ) ([]types.NodeLabel, []types.Relationship, *types.Statistics)
ProcessNonAPOCSchema serves as an alternative to ProcessAPOCSchema for environments where APOC procedures are not available. It converts schema data gathered from multiple separate, native Cypher queries (providing node counts, property maps, etc.) into the same standardized, structured format.
Types ¶
This section is empty.