While each Modus SDK offers similar capabilities, the APIs and usage may vary between languages.Modus Neo4j APIs documentation is available on the following pages:
The Modus Neo4j APIs allow you to run queries and mutations against a Neo4j database.

Import

To begin, import the neo4j package from the SDK:
import "github.com/hypermodeinc/modus/sdk/go/pkg/neo4j"

Neo4j APIs

The APIs in the neo4j package are below, organized by category.
We’re constantly introducing new APIs through ongoing development with early users. Please open an issue if you have ideas on what would make Modus even more powerful for your next app!

Functions

ExecuteQuery

Executes a Cypher query on the Neo4j database.
func ExecuteQuery(
  connection,
  query string,
  parameters map[string]any,
  opts ...Neo4jOption
) (*EagerResult, error)
connection
string
required
Name of the connection, as defined in the manifest.
query
string
required
A Neo4j Cypher query to execute.
parameters
map[string]any
required
A map of parameters to pass to the query.
opts
Neo4jOption
Optional arguments to pass to the query. Specify the database name using the WithDbName option.

GetProperty

Get a property from an entity at a given key and cast or decode it to a specific type.
func GetProperty[T PropertyValue](e Entity, key string) (T, error)
T
PropertyValue
required
The type to cast or decode the value to.
e
Entity
required
The entity to get the value from.
key
string
required
The key of the value to get.

GetRecordValue

Get a value from a record at a given key and cast or decode it to a specific type.
func GetRecordValue[T RecordValue](record *Record, key string) (T, error)
T
RecordValue
required
The type to cast or decode the value to.
record
*Record
required
The record to get the value from.
key
string
required
The key of the value to get.

Types

EagerResult

The result of a Neo4j query or mutation.
type EagerResult struct {
  Keys    []string
  Records []*Record
}
Keys
[]string
The keys of the result.
Records
[]*Record
The records of the result.

Entity

An interface representing possible entities in a Neo4j query result.
type Entity interface {
  GetElementId() string
  GetProperties() map[string]any
}
GetElementId()
method
Returns the ID of the entity.
GetProperties()
method
Returns the properties of the entity.

Node

A node in a Neo4j query result.
type Node struct {
  ElementId string
  Labels    []string
  Props     map[string]any
}
ElementId
string
The ID of the node.
Labels
[]string
The labels of the node.
Props
map[string]any
The properties of the node.
GetElementId()
method
Returns the ID of the node.
GetProperties()
method
Returns the properties of the node.

Path

A path in a Neo4j query result.
type Path struct {
  Nodes         []Node
  Relationships []Relationship
}
Nodes
[]Node
The nodes in the path.
Relationships
[]Relationship
The relationships in the path.

Point2D

A 2D point in a Neo4j query result.
type Point2D struct {
  X            float64
  Y            float64
  SpatialRefId uint32
}
X
float64
The X coordinate of the point.
Y
float64
The Y coordinate of the point.
SpatialRefId
uint32
The spatial reference ID of the point.

Point3D

A 3D point in a Neo4j query result.
type Point3D struct {
  X            float64
  Y            float64
  Z            float64
  SpatialRefId uint32
}
X
float64
The X coordinate of the point.
Y
float64
The Y coordinate of the point.
Z
float64
The Z coordinate of the point.
SpatialRefId
uint32
The spatial reference ID of the point.

PropertyValue

A type constraint for retrieving property values from a Neo4j entity.
type PropertyValue interface {
  bool | int64 | float64 | string |
    time.Time | []byte | []any | Point2D | Point3D
}

Record

A record in a Neo4j query result.
type Record struct {
  Keys   []string
  Values []string
}
Values
[]string
The values of the record.
Keys
[]string
The keys of the record.
Get(key)
method
Get the value of a record at a given key as a JSON encoded string.
Usually, you should use the GetRecordValue[T](key) function instead of this method.
AsMap()
method
Convert the record to a map of keys and JSON encoded string values.

RecordValue

A type constraint for retrieving values from a Neo4j record.
type RecordValue interface {
  bool | int64 | float64 | string | time.Time |
  []byte | []any | map[string]any |
  Node | Relationship | Path | Point2D | Point3D
}

Relationship

A relationship in a Neo4j query result.
type Relationship struct {
  ElementId      string
  StartElementId string
  EndElementId   string
  Type           string
  Props          map[string]any
}
ElementId
string
The ID of the relationship.
StartElementId
string
The ID of the start node.
EndElementId
string
The ID of the end node.
Type
string
The type of the relationship.
Props
map[string]any
The properties of the relationship.
GetElementId()
method
Returns the ID of the node.
GetProperties()
method
Returns the properties of the node.