opencypher

package
v1.8.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 16 Imported by: 0

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

View Source
const (
	CodeMalformedQuery      = "MalformedQueryException"
	CodeUnsupported         = "UnsupportedOperationException"
	CodeConstraintViolation = "ConstraintViolationException"
	CodeInvalidParameter    = "InvalidParameterException"
)

Error codes match the Neptune openCypher HTTP API.

View Source
const IDProperty = "~id"

IDProperty is the property key that sets or reads an entity id.

Variables

This section is empty.

Functions

func ParseParameters

func ParseParameters(raw string) (map[string]any, error)

ParseParameters decodes Neptune's `parameters` JSON object into engine values.

Types

type Error

type Error struct {
	Code   string
	Detail string
}

Error is a query failure carrying the Neptune error code.

func AsError

func AsError(err error) (*Error, bool)

AsError extracts an *Error from err.

func (*Error) Error

func (e *Error) Error() string

type Graph

type Graph struct {
	// contains filtered or unexported fields
}

Graph is a thread-safe in-memory property graph with an openCypher executor.

func NewGraph

func NewGraph() *Graph

NewGraph returns an empty graph.

func (*Graph) Counts

func (g *Graph) Counts() (int, int)

Counts returns the number of nodes and relationships.

func (*Graph) Execute

func (g *Graph) Execute(ctx context.Context, src string, params map[string]any) (*Result, error)

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 Path

type Path struct {
	Nodes []*Node
	Rels  []*Rel
}

Path is an alternating node/relationship walk.

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

type Result struct {
	Columns []string
	Rows    [][]any
}

Result is the table produced by RETURN; a query with no RETURN has no columns.

func (*Result) MarshalJSON

func (r *Result) MarshalJSON() ([]byte, error)

MarshalJSON renders the rows as Neptune's openCypher results array (entities use ~id/~entityType shapes).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL