Add replacement key for replaceable/addressable events. Update constraints/indexes.

This commit is contained in:
Jay
2026-05-21 12:52:00 -04:00
parent 24a76b23ce
commit 96693304e8
2 changed files with 60 additions and 11 deletions
+36 -4
View File
@@ -11,10 +11,11 @@ import (
func NewSimpleMatchKeys() *SimpleMatchKeys {
return &SimpleMatchKeys{
Keys: map[string][]string{
"User": {"pubkey"},
"Relay": {"url"},
"Event": {"id"},
"Tag": {"name", "value"},
"User": {"pubkey"},
"Relay": {"url"},
"Event": {"id"},
"Tag": {"name", "value"},
"ReplacementKey": {"pubkey", "kind"},
},
}
}
@@ -41,6 +42,13 @@ func NewTagNode(name string, value string) *Node {
"value": value})
}
func NewReplacementKeyNode(pubkey string, kind int) *Node {
return NewNode("ReplacementKey", Properties{
"pubkey": pubkey,
"kind": kind,
})
}
// ========================================
// Relationship Constructors
// ========================================
@@ -70,6 +78,30 @@ func NewReferencesUserRel(
"REFERENCES", "Tag", "User", start, end, props)
}
func NewIsReplaceableRel(
start *Node, end *Node, props Properties) *Relationship {
return NewRelationshipWithValidation(
"IS_REPLACEABLE", "Event", "ReplacementKey", start, end, props)
}
func NewForUserRel(
start *Node, end *Node, props Properties) *Relationship {
return NewRelationshipWithValidation(
"FOR_USER", "ReplacementKey", "User", start, end, props)
}
func NewWithDTagRel(
start *Node, end *Node, props Properties) *Relationship {
return NewRelationshipWithValidation(
"WITH_D_TAG", "ReplacementKey", "Tag", start, end, props)
}
func NewReferencesReplacementKeyRel(
start *Node, end *Node, props Properties) *Relationship {
return NewRelationshipWithValidation(
"REFERENCES", "Tag", "ReplacementKey", start, end, props)
}
// ========================================
// Relationship Constructor Helpers
// ========================================