Documentation
¶
Overview ¶
Package opencypher is an in-process openCypher engine over an in-memory property graph.
Supported: MATCH, OPTIONAL MATCH, WHERE, CREATE, MERGE (ON CREATE/ON MATCH SET), SET, REMOVE, DELETE, DETACH DELETE, WITH, UNWIND, RETURN with DISTINCT, ORDER BY, SKIP, LIMIT, parameters, variable-length relationships, CASE, list/map expressions, the common scalar functions and the count, collect, sum, avg, min and max aggregates. Not supported: CALL, UNION, FOREACH, LOAD CSV, pattern predicates in WHERE, list comprehensions, shortestPath, constraints and indexes.
Index ¶
- Constants
- func Explain(src, mode string) (string, error)
- func ParseParameters(raw string) (map[string]any, error)
- type Error
- type Graph
- func (g *Graph) Begin(ctx context.Context) (*Tx, error)
- func (g *Graph) Counts() (int, int)
- func (g *Graph) Execute(ctx context.Context, src string, params map[string]any) (*Result, error)
- func (g *Graph) Export(ctx context.Context) ([]byte, error)
- func (g *Graph) Import(ctx context.Context, data []byte) error
- func (g *Graph) Update(ctx context.Context, fn func(*Store) error) error
- func (g *Graph) View(ctx context.Context, fn func(*Store) error) error
- type Node
- type Path
- type Rel
- type Result
- type Store
- func (s *Store) AddNode(id string, labels []string, props map[string]any) (*Node, error)
- func (s *Store) AddRel(id, typ string, from, to *Node, props map[string]any) (*Rel, error)
- func (s *Store) DeleteNode(n *Node)
- func (s *Store) DeleteRel(r *Rel)
- func (s *Store) InRels(id string) []*Rel
- func (s *Store) Node(id string) *Node
- func (s *Store) Nodes() []*Node
- func (s *Store) OutRels(id string) []*Rel
- func (s *Store) Rel(id string) *Rel
- func (s *Store) Rels() []*Rel
- type Tx
Constants ¶
const ( CodeMalformedQuery = "MalformedQueryException" CodeUnsupported = "UnsupportedOperationException" CodeConstraintViolation = "ConstraintViolationException" CodeInvalidParameter = "InvalidParameterException" )
Error codes match the Neptune openCypher HTTP API.
const IDProperty = "~id"
IDProperty is the property key that sets or reads an entity id.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
Graph is a thread-safe in-memory property graph with an openCypher executor.
func (*Graph) Execute ¶
Execute runs one openCypher query. Write queries are atomic: a failure leaves the graph unchanged.
type Node ¶
type Node struct {
Props map[string]any
ID string
Labels []string
// contains filtered or unexported fields
}
Node is a labelled vertex.
type Rel ¶
type Rel struct {
Props map[string]any
ID string
Type string
Start string
End string
// contains filtered or unexported fields
}
Rel is a directed, typed edge.
type Result ¶
Result is the table produced by RETURN; a query with no RETURN has no columns.
func (*Result) MarshalJSON ¶
MarshalJSON renders the rows as Neptune's openCypher results array (entities use ~id/~entityType shapes).
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is exclusive access to a graph's entities, handed to other query languages (Gremlin) so they share the same data, locking and rollback as openCypher.
func (*Store) DeleteNode ¶
DeleteNode removes a node and its relationships.
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
Tx is an explicit transaction holding the graph exclusively until Commit or Rollback.
func (*Tx) Commit ¶
func (t *Tx) Commit()
Commit keeps the transaction's writes and releases the graph.