update code header format
This commit is contained in:
@@ -5,10 +5,6 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// ========================================
|
||||
// Cypher Formatting Functions
|
||||
// ========================================
|
||||
|
||||
// ToCypherLabel converts a node label or relationship type into its Cypher
|
||||
// format.
|
||||
func ToCypherLabel(label string) string {
|
||||
|
||||
@@ -4,16 +4,16 @@ import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// ========================================
|
||||
// ----------------------------------------------------------------------------
|
||||
// Types
|
||||
// ========================================
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Properties represents a map of node or relationship props.
|
||||
type Properties map[string]any
|
||||
|
||||
// ========================================
|
||||
// ----------------------------------------------------------------------------
|
||||
// Match Key Provider
|
||||
// ========================================
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// MatchKeysProvider defines methods for querying a mapping of node labels and
|
||||
// the property keys used to match nodes with them.
|
||||
@@ -46,9 +46,9 @@ func (p *SimpleMatchKeys) GetKeys(label string) ([]string, bool) {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
// ========================================
|
||||
// ----------------------------------------------------------------------------
|
||||
// Nodes
|
||||
// ========================================
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Node represents a Neo4j node entity, encapsulating its labels and
|
||||
// properties.
|
||||
@@ -111,9 +111,9 @@ func (n *Node) Serialize() *SerializedNode {
|
||||
return &n.Props
|
||||
}
|
||||
|
||||
// ========================================
|
||||
// ----------------------------------------------------------------------------
|
||||
// Relationships
|
||||
// ========================================
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Relationship represents a Neo4j relationship between two nodes, including
|
||||
// its type and properties.
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
package heartwood
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/neo4j/neo4j-go-driver/v6/neo4j"
|
||||
)
|
||||
|
||||
// ========================================
|
||||
// ----------------------------------------------------------------------------
|
||||
// Schema Match Keys
|
||||
// ========================================
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
func NewSimpleMatchKeys() *SimpleMatchKeys {
|
||||
return &SimpleMatchKeys{
|
||||
Keys: map[string][]string{
|
||||
"User": {"pubkey"},
|
||||
"Relay": {"url"},
|
||||
"Event": {"id"},
|
||||
"Tag": {"name", "value"},
|
||||
"ReplacementKey": {"pubkey", "kind"},
|
||||
@@ -20,9 +21,9 @@ func NewSimpleMatchKeys() *SimpleMatchKeys {
|
||||
}
|
||||
}
|
||||
|
||||
// ========================================
|
||||
// ----------------------------------------------------------------------------
|
||||
// Node Constructors
|
||||
// ========================================
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
func NewUserNode(pubkey string) *Node {
|
||||
return NewNode("User", Properties{"pubkey": pubkey})
|
||||
@@ -49,9 +50,9 @@ func NewReplacementKeyNode(pubkey string, kind int) *Node {
|
||||
})
|
||||
}
|
||||
|
||||
// ========================================
|
||||
// ----------------------------------------------------------------------------
|
||||
// Relationship Constructors
|
||||
// ========================================
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
func NewSignedRel(
|
||||
start *Node, end *Node, props Properties) *Relationship {
|
||||
@@ -102,9 +103,9 @@ func NewReferencesReplacementKeyRel(
|
||||
"REFERENCES", "Tag", "ReplacementKey", start, end, props)
|
||||
}
|
||||
|
||||
// ========================================
|
||||
// ----------------------------------------------------------------------------
|
||||
// Relationship Constructor Helpers
|
||||
// ========================================
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
func validateNodeLabel(node *Node, role string, expectedLabel string) {
|
||||
if !node.Labels.Contains(expectedLabel) {
|
||||
|
||||
Reference in New Issue
Block a user