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 namespace from the SDK:
import { neo4j } from "@hypermode/modus-sdk-as"

Neo4j APIs

The APIs in the neo4j namespace 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.
function executeQuery(
  connection: string,
  query: string,
  parameters: Variables = new Variables(),
  dbName: string = "neo4j",
): EagerResult
connection
string
required
Name of the connection, as defined in the manifest.
query
string
required
A Neo4j Cypher query to execute.
parameters
Variables
The parameters to pass to the query.
dbName
string
An optional database name to use. Defaults to “neo4j” if not provided.

Types

EagerResult

The result of a Neo4j query.
class EagerResult {
  Keys: string[]
  Records: Record[]
}
keys
string[]
The keys of the result.
records
Record[]
The records of the result.

Entity

An abstract class representing possible entities in a Neo4j query result.
abstract class Entity {
  elementId: string
  props: DynamicMap
}
elementId
string
The ID of the entity.
props
DynamicMap
The properties of the entity.

Node

A node in a Neo4j query result.
class Node extends Entity {
  elementId: string // from base class
  props: DynamicMap // from base class
  labels: string[]
}
elementId
string
The ID of the node.
props
DynamicMap
The properties of the node.
labels
string[]
The labels of the node.

Path

A path in a Neo4j query result.
class Path {
  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.
class Point2D {
  x: f64
  y: f64
  spatialRefId: u32
}
x
f64
The X coordinate of the point.
y
f64
The Y coordinate of the point.
spatialRefId
u32
The spatial reference ID of the point.

Point3D

A 3D point in a Neo4j query result.
class Point3D {
  x: f64
  y: f64
  z: f64
  spatialRefId: u32
}
x
f64
The X coordinate of the point.
y
f64
The Y coordinate of the point.
z
f64
The Z coordinate of the point.
spatialRefId
u32
The spatial reference ID of the point.

Record

A record in a Neo4j query result.
class Record {
  keys: string[]
  values: string[]
  get(key: string): string
  getValue<T>(key: string): T
  asMap(): Map<string, string>
}
keys
string[]
The keys of the record.
values
string[]
The values of the record.
get(key)
method
Get a value from a record at a given key as a JSON encoded string.
Usually, you should use getValue<T>(key) instead of this method.
getValue<T>(key)
method
Get a value from a record at a given key and cast or decode it to a specific type.
asMap()
method
Convert the record to a map of keys and JSON encoded string values.

Relationship

A relationship in a Neo4j query result.
class Relationship extends Entity {
  elementId: string // from base class
  props: DynamicMap // from base class
  startElementId: string
  endElementId: string
  type: string
}
elementId
string
The ID of the relationship.
props
DynamicMap
The properties 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.