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.
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)
A Neo4j Cypher query to execute.
A map of parameters to pass to the query.
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)
The type to cast or decode the value to.
The entity to get the value from.
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)
The type to cast or decode the value to.
The record to get the value from.
The key of the value to get.
EagerResult
The result of a Neo4j query or mutation.
type EagerResult struct {
Keys []string
Records []*Record
}
The records of the result.
An interface representing possible entities in a Neo4j query result.
type Entity interface {
GetElementId() string
GetProperties() map[string]any
}
Returns the ID of the entity.
Returns the properties of the entity.
A node in a Neo4j query result.
type Node struct {
ElementId string
Labels []string
Props map[string]any
}
The properties of the node.
Returns the ID of the node.
Returns the properties of the node.
A path in a Neo4j query result.
type Path struct {
Nodes []Node
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
}
The X coordinate of the point.
The Y coordinate of the point.
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
}
The X coordinate of the point.
The Y coordinate of the point.
The Z coordinate of the point.
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
}
A record in a Neo4j query result.
type Record struct {
Keys []string
Values []string
}
The values of the record.
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.
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
}
The ID of the relationship.
The ID of the start node.
The type of the relationship.
The properties of the relationship.
Returns the ID of the node.
Returns the properties of the node.