Files
ax/store/store.go

32 lines
1.3 KiB
Go

package store
import "axolotl/models"
// Store is a primitive graph persistence interface. It provides basic
// operations for nodes, tags, and directed edges. No business logic lives here.
type Store interface {
// Nodes
AddNode(id, title, content, dueDate, createdAt, updatedAt string) error
GetNode(id string) (*models.Node, error) // returns node with tags and edges populated
UpdateNode(id, title, content, dueDate, updatedAt string) error // empty dueDate stores NULL
DeleteNode(id string) error
NodeExists(id string) (bool, error)
GenerateID() (string, error) // returns a random 5-char ID guaranteed unique in the store
// Tags
AddTag(nodeID, tag string) error
RemoveTag(nodeID, tag string) error
// Edges (directed, typed)
AddEdge(fromID, toID string, relType models.RelType) error
RemoveEdge(fromID, toID string, relType models.RelType) error
// Query returns fully-populated nodes matching all given tag prefixes and edge filters.
FindNodes(tagPrefixes []string, edgeFilters []*models.Rel) ([]*models.Node, error)
// Transaction runs fn inside an atomic transaction. If fn returns an error
// the transaction is rolled back; otherwise it is committed.
// Calls to Transaction inside fn reuse the same transaction (no nesting).
Transaction(fn func(Store) error) error
}