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)

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

Get the count of Relationships of a Direction for a Node

number NodeGetDegreeForDirection()

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

number NodeGetDegreeForDirectionForType()

Get the count of Relationships of a Type for a Node

number NodeGetDegreeForType()

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

number NodeGetDegreeForDirectionForTypes()

Get the count of Relationships of Types for a Node

number NodeGetDegreeForTypes()

Get the count of Relationships for a Node by Id

number NodeGetDegreeById()

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

number NodeGetDegreeByIdForDirection()

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

number NodeGetDegreeByIdForDirectionForType()

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

number NodeGetDegreeByIdForType()

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

number NodeGetDegreeByIdForDirectionForTypes()

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

number NodeGetDegreeByIdForTypes()

Traversing - Relationship Ids

Get the Relationships Ids for a Node

[Link] NodeGetRelationshipsIds()

Get the Relationships Ids of a Direction for a Node

[Link] NodeGetRelationshipsIdsForDirection()

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

[Link] NodeGetRelationshipsIdsForDirectionForType()

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

[Link] NodeGetRelationshipsIdsForDirectionForTypeId()

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

[Link] NodeGetRelationshipsIdsForDirectionForTypes()

Get the Relationships Ids of a Type for a Node

[Link] NodeGetRelationshipsIdsForType()

Get the Relationships Ids of a Type Id for a Node

[Link] NodeGetRelationshipsIdsForDirectionForTypeId()

Get the Relationships Ids of Types for a Node

[Link] NodeGetRelationshipsIdsForTypes()

Get the Relationships Ids for a Node by Id

[Link] NodeGetRelationshipsIdsById()

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

[Link] NodeGetRelationshipsIdsByIdForDirection()

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

[Link] NodeGetRelationshipsIdsByIdForDirectionForType()

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

[Link] NodeGetRelationshipsIdsByIdForDirectionForTypeId()

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

[Link] NodeGetRelationshipsIdsByIdForDirectionForTypes()

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

[Link] NodeGetRelationshipsIdsByIdForType()

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

[Link] NodeGetRelationshipsIdsByIdForDirectionForTypeId()

Get the Relationships Ids of Types for a Node by Id

[Link] NodeGetRelationshipsIdsByIdForTypes()

Traversing - Relationships

Get the Relationships for a Node

[Relationship] NodeGetRelationships()

Get the Relationships of a Direction for a Node

[Relationship] NodeGetRelationshipsForDirection()

Get the Relationships of a Direction and Type for a Node

[Relationship] NodeGetRelationshipsForDirectionForType()

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

[Relationship] NodeGetRelationshipsForDirectionForTypeId()

Get the Relationships of a Direction and Types for a Node

[Relationship] NodeGetRelationshipsForDirectionForTypes()

Get the Relationships of a Type for a Node

[Relationship] NodeGetRelationshipsForType()

Get the Relationships of a Type Id for a Node

[Relationship] NodeGetRelationshipsForDirectionForTypeId()

Get the Relationships of Types for a Node

[Relationship] NodeGetRelationshipsForTypes()

Get the Relationships for a Node by Id

[Relationship] NodeGetRelationshipsById()

Get the Relationships of a Direction for a Node by Id

[Relationship] NodeGetRelationshipsByIdForDirection()

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

[Relationship] NodeGetRelationshipsByIdForDirectionForType()

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

[Relationship] NodeGetRelationshipsByIdForDirectionForTypeId()

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

[Relationship] NodeGetRelationshipsByIdForDirectionForTypes()

Get the Relationships of a Type for a Node by Id

[Relationship] NodeGetRelationshipsByIdForType()

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

[Relationship] NodeGetRelationshipsByIdForDirectionForTypeId()

Get the Relationships of Types for a Node by Id

[Relationship] NodeGetRelationshipsByIdForTypes()

Traversing - Neighbors

Get the Neighbors for a Node

[Node] NodeGetNeighbors()

Get the Neighbors of a Direction for a Node

[Node] NodeGetNeighborssForDirection()

Get the Neighbors of a Direction and Type for a Node

[Node] NodeGetNeighborsForDirectionForType()

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

[Node] NodeGetNeighborsForDirectionForTypeId()

Get the Neighbors of a Direction and Types for a Node

[Node] NodeGetNeighborsForDirectionForTypes()

Get the Neighbors of a Type for a Node

[Node] NodeGetNeighborsForType()

Get the Neighbors of a Type Id for a Node

[Node] NodeGetNeighborsForDirectionForTypeId()

Get the Neighbors of Types for a Node

[Node] NodeGetNeighborsForTypes()

Get the Neighbors for a Node by Id

[Node] NodeGetNeighborsById()

Get the Neighbors of a Direction for a Node by Id

[Node] NodeGetNeighborsByIdForDirection()

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

[Node] NodeGetNeighborsByIdForDirectionForType()

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

[Node] NodeGetNeighborsByIdForDirectionForTypeId()

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

[Node] NodeGetNeighborsByIdForDirectionForTypes()

Get the Neighbors of a Type for a Node by Id

[Node] NodeGetNeighborsByIdForType()

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

[Node] NodeGetNeighborsByIdForDirectionForTypeId()

Get the Neighbors of Types for a Node by Id

[Node] NodeGetNeighborsByIdForTypes()

All

Get all the Node Ids

[number] AllNodeIds()

Get all the Nodes Ids of a Type

[number] AllNodeIdsForType()

Get all the Relationship Ids

[number] AllRelationshipIds()

Get all the Relationship Ids of a Type

[number] AllRelationshipIdsForType()

Get all the Nodes

[Node] AllNodes()

Get all the Nodes of a Type

[Node] AllNodesForType()

Get all the Relationships

[Relationship] AllRelationships()

Get all the Relationships of a Type

[Relationship] AllRelationshipsForType()