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