Lua API

Overview

The Lua API can be accessed via an HTTP request using the POST method to /db/{graph}/lua and providing a script in text format. The last line of the script will be converted in to JSON and returned in an Array. For more information on how this works please refer to this blog post.

There are 3 usertypes in our implementation: Node, Relationship and Link. Nodes and relationships are pretty self explanatory, a Link is the combination of node_id and relationship_id in a relationship chain.

Each Shard can run only one Lua script concurrently. The following methods are currently available:

Relationship Types

Retrieve the count of Relationship Types

Number RelationshipTypesGetCount()

Retrieve the count of a Relationship Type

Number RelationshipTypesGetCount(String type)

Retrieve the Relationship Types in an Array

String[] RelationshipTypesGet()

Relationship Type

Retrieve the Type of a Relationship Type Id

String RelationshipTypeGetType(Number type_id)

Insert a Relationship Type and return its Type Id

Number RelationshipTypeInsert(String type)

Node Types

Retrieve the count of Node Types

Number NodeTypesGetCount()

Retrieve the count of a Node Type

Number NodeTypesGetCount(String type)

Retrieve the Node Types in an Array

String[] NodeTypesGet()

Node Type

Retrieve the Type of a Node Type Id

String NodeTypeGetType(Number type_id)

Insert a Node Type and return its Type Id

Number NodeTypeInsert(String type)

Data Types

RageDB currently supports booleans, 64-bit integers, 64-bit doubles, strings and lists of the preceding data types:

boolean, integer, double, string, boolean_list, integer_list, double_list, string_list

Property Types

Add a property to a Node Type

Number NodePropertyTypeAdd(String node_type, String property, String data_type)

Add a property to a Relationship Type

Number RelationshipPropertyTypeAdd(String relationship_type, String property, String data_type)

Remove a property from a Node Type

Boolean NodePropertyTypeDelete(String node_type, String property)

Remove a property from a Relationship Type

Boolean RelationshipPropertyTypeDelete(String relationship_type, String property)

Nodes

Add a Node with properties

Number NodeAdd(String type, String key, String json)

Add an empty Node

Number NodeAddEmpty(String type, String key)

Get a Node by Type and Key

Node NodeGet(String type, String key)

Get a Node by Id

Node NodeGet(Number id)

Get a Node Id by Type and Key

Number NodeGetId(String type, String key)

Get the Key of a Node by Id

String NodeGetKey(Number id)

Get the Type of a Node by Id

String NodeGetType(Number id)

Remove a Node by Type and Key

Boolean NodeRemove(String type, String key)

Remove a Node by Id

Boolean NodeRemove(Number id)

Return a list of Nodes by their Node Ids

Node[] NodesGet(Number[] ids)

Node Properties

Delete a Node Property

Boolean NodePropertyDelete(String type, String key, String property)

Delete a Node Property By Id

Boolean NodePropertyDelete(Number id, String property)

Get a Node Property

sol::object NodePropertyGet(String type, String key, String property)

Get a Node Property By Id

sol::object NodePropertyGet(Number id, String property)

Set a Node Property

Boolean NodePropertySet(String type, String key, String property, sol::object value)

Set a Node Property By Id

Boolean NodePropertySet(Number id, String property, sol::object value)

Delete all Node Properties

Boolean NodePropertiesDelete(String type, String key)

Delete all Node Properties By Id

Boolean NodePropertiesDelete(Number id)

Get a Node Properties

sol::object NodePropertiesGet(String type, String key)

Get a Node Properties By Id

sol::object NodePropertiesGet(Number id)

Reset a Node Properties

Boolean NodePropertiesResetFromJson(String type, String key, String json)

Reset a Node Properties By Id

Boolean NodePropertiesResetFromJson(Number id, String json)

Set some Node Properties

Boolean NodePropertiesSetFromJson(String type, String key, String json)

Set some Node Properties By Id

Boolean NodePropertiesSetFromJson(Number id, String json)

Relationship Properties

Delete a Relationship Property

Boolean RelationshipPropertyDelete(Number id, String property)

Get a Relationship Property

sol::object RelationshipPropertyGet(Number id, String property)

Set a Relationship Property

Boolean RelationshipPropertySet(Number id, String property, sol::object value)

Delete all Relationship Properties

Boolean RelationshipPropertiesDelete(Number id)

Get a Relationship Properties

sol::object RelationshipPropertiesGet(Number id)

Reset a Relationship Properties

Boolean RelationshipPropertiesResetFromJson(Number id, String json)

Set some Relationship Properties

Boolean RelationshipPropertiesSetFromJson(Number id, String json)

Relationships

Add an empty Relationship

Number RelationshipAddEmpty(String rel_type, String type1, String key1, String type2, String key2)

Add an empty Relationship by Node Ids

Number RelationshipAddEmptys(String rel_type, Number id1, Number id1)

Add a Relationship with properties

Number RelationshipAdd(String rel_type, String type1, String key1, String type2, String key2, String json)

Add a Relationship with properties By Node Ids

Number RelationshipAdds(String rel_type, Number id1, Number id1, String json)

Get a Relationship

Relationship RelationshipGet(Number id)

Return a list of Relationships by their Relationship Ids

Relationship[] RelationshipsGet(Number[] ids)

Remove a Relationship

Boolean RelationshipRemove(Number id)

Get the Type of a Relationship

String RelationshipGetType(Number id)

Get the Starting Node Id of a Relationship

Number RelationshipGetStartingNodeId(Number id)

Get the Ending Node Id of a Relationship

Number RelationshipGetEndingNodeId(Number id)

Node Degree

Get the count of Relationships for a Node

Number NodeGetDegree(String type, String key)

Get the count of Relationships of a Direction for a Node

Number NodeGetDegree(String type, String key, Direction direction)

Get the count of Relationships of a Direction and Type for a Node

Number NodeGetDegree(String type, String key, Direction direction, String rel_type)

Get the count of Relationships of a Type for a Node

Number NodeGetDegree(String type, String key, String rel_type)

Get the count of Relationships of a Direction and Types for a Node

Number NodeGetDegree(String type, String key, Direction direction, String[] rel_types)

Get the count of Relationships of Types for a Node

Number NodeGetDegree(String type, String key, String[] rel_types)

Get the count of Relationships for a Node by Id

Number NodeGetDegree(Number id)

Get the count of Relationships of a Direction for a Node by Id

Number NodeGetDegree(Number id, Direction direction)

Get the count of Relationships of a Direction and Type for a Node by Id

Number NodeGetDegree(Number id, Direction direction, String rel_type)

>Get the count of Relationships of a Type for a Node by Id

Number NodeGetDegree(Number id, String rel_type)

Get the count of Relationships of a Direction and Types for a Node by Id

Number NodeGetDegree(Number id, Direction direction, String[] rel_types)

Get the count of Relationships of Types for a Node by Id

Number NodeGetDegree(Number id, String[] rel_types)

Traversing - Node Links

Get the Links for a Node

Link[] NodeGetLinks(String type, String key)

Get the Links of a Direction for a Node

Link[] NodeGetLinks(String type, String key, Direction direction)

Get the Links of a Direction and Type for a Node

Link[] NodeGetLinks(String type, String key, Direction direction, String rel_type)

Get the Links of a Direction and Types for a Node

Link[] NodeGetLinks(String type, String key, Direction direction, String[] rel_types)

Get the Links of a Type for a Node

Link[] NodeGetLinks(String type, String key, String rel_type)

Get the Links of Types for a Node

Link[] NodeGetLinks(String type, String key, Direction direction, String[] rel_types)

Get the Links for a Node by Id

Link[] NodeGetLinks(Number id)

Get the Links of a Direction for a Node by Id

Link[] NodeGetLinks(Number id, Direction direction)

Get the Links of a Direction and Type for a Node by Id

Link[] NodeGetLinks(Number id, Direction direction, String rel_type)

Get the Links of a Direction and Types for a Node by Id

Link[] NodeGetLinks(Number id, String[] rel_types)

Get the Links of a Type for a Node by Id

Link[] NodeGetLinks(Number id, String rel_type)

Get the Links of Types for a Node by Id

Link[] NodeGetLinks(Number id, String[] rel_types)

Traversing - Relationships

Get the Relationships for a Node

Relationship[] NodeGetRelationships(String type, String key)

Get the Relationships of a Direction for a Node

Relationship[] NodeGetRelationships(String type, String key, Direction direction)

Get the Relationships of a Direction and Type for a Node

Relationship[] NodeGetRelationships(String type, String key, Direction direction, String rel_type)

Get the Relationships of a Direction and Types for a Node

Relationship[] NodeGetRelationships(String type, String key, Direction direction, String[] rel_types)

Get the Relationships of a Type for a Node

Relationship[] NodeGetRelationships(String type, String key, String rel_type)

Get the Relationships of Types for a Node

Relationship[] NodeGetRelationships(String type, String key, Direction direction, String[] rel_types)

Get the Relationships for a Node by Id

Relationship[] NodeGetRelationships(Number id)

Get the Relationships of a Direction for a Node by Id

Relationship[] NodeGetRelationships(Number id, Direction direction)

Get the Relationships of a Direction and Type for a Node by Id

Relationship[] NodeGetRelationships(Number id, Direction direction, String rel_type)

Get the Relationships of a Direction and Types for a Node by Id

Relationship[] NodeGetRelationships(Number id, Direction direction, String[] rel_types)

Get the Relationships of a Type for a Node by Id

Relationship[] NodeGetRelationships(Number id, String rel_type)

Get the Relationships of Types for a Node by Id

Relationship[] NodeGetRelationships(Number id, String[] rel_types)

Traversing - Neighbors

Get the Neighbors for a Node

Node[] NodeGetNeighbors(String type, String key)

Get the Neighbors of a Direction for a Node

Node[] NodeGetNeighbors(String type, String key, Direction direction)

Get the Neighbors of a Direction and Type for a Node

Node[] NodeGetNeighbors(String type, String key, Direction direction, String rel_type)

Get the Neighbors of a Direction and Types for a Node

Node[] NodeGetNeighbors(String type, String key, Direction direction, String[] rel_types)

Get the Neighbors of a Type for a Node

Node[] NodeGetNeighbors(String type, String key, String rel_type)

Get the Neighbors of Types for a Node

Node[] NodeGetNeighbors(String type, String key, String[] rel_types)

Get the Neighbors for a Node by Id

Node[] NodeGetNeighbors(Number id)

Get the Neighbors of a Direction for a Node by Id

Node[] NodeGetNeighbors(Number id, Direction direction)

Get the Neighbors of a Direction and Type for a Node by Id

Node[] NodeGetNeighbors(Number id, Direction direction, String rel_type)

Get the Neighbors of a Direction and Types for a Node by Id

Node[] NodeGetNeighbors(Number id, Direction direction, String[] rel_types)

Get the Neighbors of a Type for a Node by Id

Node[] NodeGetNeighbors(Number id, String rel_type)

Get the Neighbors of Types for a Node by Id

Node[] NodeGetNeighbors(Number id, String[] rel_types)

All

Get all the Node Ids

Number[] AllNodeIds()

Get all the Nodes Ids of a Type

Number[] AllNodeIds(String type)

Get all the Relationship Ids

Number[] AllRelationshipIds()

Get all the Relationship Ids of a Type

Number[] AllRelationshipIds(String type)

Get all the Nodes

Node[] AllNodes()

Get all the Nodes of a Type

Node[] AllNodes(String type)

Get all the Relationships

Relationship[] AllRelationships()

Get all the Relationships of a Type

Relationship[] AllRelationships(String type)