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 RelationshipTypesGetCountByType(String type)

Retrieve the count of a Relationship Type by Type Id

Number RelationshipTypesGetCountById(Number type_id)

Retrieve the Relationship Types in an Array

String[] RelationshipTypesGet()

Relationship Type

Retrieve the Type of a Relationship Type Id

String RelationshipTypeGetType(Number type_id)

Retrieve the Type Id of a Relationship by Type

Number RelationshipTypeGetTypeId(String type)

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 NodeTypesGetCountByType(String type)

Retrieve the count of a Node Type by Type Id

Number NodeTypesGetCountById(Number type_id)

Retrieve the Node Types in an Array

String[] NodeTypesGet()

Node Type

Retrieve the Type of a Node Type Id

String NodeTypeGetType(Number type_id)

Retrieve the Type Id of a Node by Type

Number NodeTypeGetTypeId(String type)

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 NodeGetById(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)

Get the Type Id of a Node by Id

Number NodeGetTypeId(Number id)

Remove a Node by Type and Key

Boolean NodeRemove(String type, String key)

Remove a Node by Id

Boolean NodeRemoveById(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 NodePropertyDeleteById(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 NodePropertyGetById(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 NodePropertySetById(Number id, String property, sol::object value)

Delete all Node Properties

Boolean NodePropertiesDelete(String type, String key)

Delete all Node Properties By Id

Boolean NodePropertiesDeleteById(Number id)

Get a Node Properties

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

Get a Node Properties By Id

sol::object NodePropertiesGetById(Number id)

Reset a Node Properties

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

Reset a Node Properties By Id

Boolean NodePropertiesResetFromJsonById(Number id, String json)

Set some Node Properties

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

Set some Node Properties By Id

Boolean NodePropertiesSetFromJsonById(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 Type Id and Node Ids

Number RelationshipAddEmptyByTypeIdByIds(Number rel_type_id, Number id1, Number id2)

Add an empty Relationship by Node Ids

Number RelationshipAddEmptyByIds(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 Type Id and Node Ids

Number RelationshipAddByTypeIdByIds(Number rel_type_id, Number id1, Number id1, String json)

Add a Relationship with properties By Node Ids

Number RelationshipAddByIds(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 Type Id of a Relationship

Number RelationshipGetTypeId(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 NodeGetDegreeForDirection(String type, String key, Direction direction)

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

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

Get the count of Relationships of a Type for a Node

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

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

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

Get the count of Relationships of Types for a Node

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

Get the count of Relationships for a Node by Id

Number NodeGetDegreeById(Number id)

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

Number NodeGetDegreeByIdForDirection(Number id, Direction direction)

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

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

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

Number NodeGetDegreeByIdForType(Number id, String rel_type)

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

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

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

Number NodeGetDegreeByIdForTypes(Number id, String[] rel_types)

Traversing - Relationship Ids

Get the Relationships Ids for a Node

Link[] NodeGetRelationshipsIds(String type, String key)

Get the Relationships Ids of a Direction for a Node

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

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

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

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

Link[] NodeGetRelationshipsIdsForDirectionForTypeId(String type, String key, Direction direction, Number type_id)

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

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

Get the Relationships Ids of a Type for a Node

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

Get the Relationships Ids of a Type Id for a Node

Link[] NodeGetRelationshipsIdsForTypeId(String type, String key, Number type_id)

Get the Relationships Ids of Types for a Node

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

Get the Relationships Ids for a Node by Id

Link[] NodeGetRelationshipsIdsById(Number id)

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

Link[] NodeGetRelationshipsIdsByIdForDirection(Number id, Direction direction)

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

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

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

Link[] NodeGetRelationshipsIdsByIdForDirectionForTypeId(Number id, Direction direction, Number type_id)

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

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

Get the Relationships Ids of a Type for a Node by Id

Link[] NodeGetRelationshipsIdsByIdForType(Number id, String rel_type)

Get the Relationships Ids of a Type Id for a Node by Id

Link[] NodeGetRelationshipsIdsByIdForDirectionForTypeId(Number id, Direction direction, Number rel_type_id)

Get the Relationships Ids of Types for a Node by Id

Link[] NodeGetRelationshipsIdsByIdForTypes(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[] NodeGetRelationshipsForDirection(String type, String key, Direction direction)

Get the Relationships of a Direction and Type for a Node

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

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

Relationship[] NodeGetRelationshipsForDirectionForTypeId(String type, String key, Direction direction, Number type_id)

Get the Relationships of a Direction and Types for a Node

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

Get the Relationships of a Type for a Node

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

Get the Relationships of a Type Id for a Node

Relationship[] NodeGetRelationshipsForDirectionForTypeId(String type, String key, Direction direction, Number type_id)

Get the Relationships of Types for a Node

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

Get the Relationships for a Node by Id

Relationship[] NodeGetRelationshipsById(Number id)

Get the Relationships of a Direction for a Node by Id

Relationship[] NodeGetRelationshipsByIdForDirection(Number id, Direction direction)

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

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

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

Relationship[] NodeGetRelationshipsByIdForDirectionForTypeId(Number id, Direction direction, Number type_id)

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

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

Get the Relationships of a Type for a Node by Id

Relationship[] NodeGetRelationshipsByIdForType(Number id, String rel_type)

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

Relationship[] NodeGetRelationshipsByIdForDirectionForTypeId(Number id, Direction direction)

Get the Relationships of Types for a Node by Id

Relationship[] NodeGetRelationshipsByIdForTypes(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[] NodeGetNeighborsForDirection(String type, String key, Direction direction)

Get the Neighbors of a Direction and Type for a Node

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

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

Node[] NodeGetNeighborsForDirectionForTypeId(String type, String key, Direction direction, Number type_id)

Get the Neighbors of a Direction and Types for a Node

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

Get the Neighbors of a Type for a Node

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

Get the Neighbors of a Type Id for a Node

Node[] NodeGetNeighborsForDirectionForTypeId(String type, String key, Direction direction, Number type_id)

Get the Neighbors of Types for a Node

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

Get the Neighbors for a Node by Id

Node[] NodeGetNeighborsById(Number id)

Get the Neighbors of a Direction for a Node by Id

Node[] NodeGetNeighborsByIdForDirection(Number id, Direction direction)

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

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

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

Node[] NodeGetNeighborsByIdForDirectionForTypeId(Number id, Direction direction, Number type_id)

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

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

Get the Neighbors of a Type for a Node by Id

Node[] NodeGetNeighborsByIdForType(Number id, String rel_type)

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

Node[] NodeGetNeighborsByIdForDirectionForTypeId(Number id, Direction direction, Number type_id)

Get the Neighbors of Types for a Node by Id

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

All

Get all the Node Ids

Number[] AllNodeIds()

Get all the Nodes Ids of a Type

Number[] AllNodeIdsForType(String type)

Get all the Relationship Ids

Number[] AllRelationshipIds()

Get all the Relationship Ids of a Type

Number[] AllRelationshipIdsForType(String type)

Get all the Nodes

Node[] AllNodes()

Get all the Nodes of a Type

Node[] AllNodesForType(String type)

Get all the Relationships

Relationship[] AllRelationships()

Get all the Relationships of a Type

Relationship[] AllRelationshipsForType(String type)