Started transforming tags into relationships.
This commit is contained in:
39
lib/write.go
Normal file
39
lib/write.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package lib
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// ========================================
|
||||
// Cypher Formatting Functions
|
||||
// ========================================
|
||||
|
||||
// ToCypherLabel converts a node label or relationship type into its Cypher
|
||||
// format.
|
||||
func ToCypherLabel(label string) string {
|
||||
return fmt.Sprintf(":`%s`", label)
|
||||
}
|
||||
|
||||
// ToCypherLabels converts a list of node labels into its Cypher format.
|
||||
func ToCypherLabels(labels []string) string {
|
||||
var cypherLabels []string
|
||||
|
||||
for _, label := range labels {
|
||||
cypherLabels = append(cypherLabels, ToCypherLabel(label))
|
||||
}
|
||||
|
||||
return strings.Join(cypherLabels, "")
|
||||
}
|
||||
|
||||
func ToCypherProps(keys []string, prefix string) string {
|
||||
if prefix == "" {
|
||||
prefix = "$"
|
||||
}
|
||||
cypherPropsParts := []string{}
|
||||
for _, key := range keys {
|
||||
cypherPropsParts = append(
|
||||
cypherPropsParts, fmt.Sprintf("%s: %s%s", key, prefix, key))
|
||||
}
|
||||
return strings.Join(cypherPropsParts, ", ")
|
||||
}
|
||||
Reference in New Issue
Block a user