helpers

package
v0.19.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToStringSlice

func ConvertToStringSlice(slice []any) []string

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

func ConvertValue(value any) any

ConvertValue converts Neo4j value to JSON-compatible value.

func GetStringValue

func GetStringValue(val any) string

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL