Neo4j API Wrapper
Yet another Neo4j REST API wrapper for io.js, which provides Promise api.
Usage
npm install neo4j-io --save var neo4j = require
API
Cypher
var cypher = 'MATCH (n:NODE) RETURN n LIMIT 1'neo4j // With paramsvar cypher = 'MATCH (n:NODE) WHERE n.name={name} RETURN n'var params = name: 'neo4j' neo4j
Node
create(node)
Create a node with JSON data
neo4jNode
get(id)
Get node with specify id
neo4jNode
update(id, prop, [value])
When prop is a string, it will update the specify property, otherwise reset node with given json
// Update nameneo4jNode // Reset nodeneo4jNode
delete(id)
Delete node
neo4jNode
deleteProperties(id, [prop])
Delete one or all properties
neo4jNodeneo4jNode
Relationship
create(from, to, type, [props])
Create a relationship between two nodes with specify type
neo4jRelationshipneo4jRelationship
get(id)
Get a relationship node
getProperties(id, [prop])
Get properties
update(id, prop, [value])
Update or reset properties
delete(id)
Delete a relationship
all(nodeId)
Get all relationships of the node
incoming(nodeId)
Get incoming relationships of the node
outgoing(nodeId)
Get outgoing relationships of the node
Label
craete(nodeId, label)
Add label to node
update(nodeId, labels)
Update labels of the node
neo4jLabelneo4jLabel
get(nodeId)
Get labels of the node
delete(nodeId, label)
nodes(label)
Get all the nodes with label
all()
Get all the labels
Index
get(label)
Get indexes for a label
create(label, index)
Create a index for a label
neo4jIndex
delete|drop(label, index)
Drop index
Batch
All the api above are available in batch operation, exec
must be called when you want
to send the requests
var batch = neo4j// Create a nodevar batchId = batchNode// Add a label to node, use id or batch IdbatchLabel// Create a relationshipbatchRelationship// Call execbatch // Batch also support cypher var c1 = 'START n=node(1) RETURN n'var c2 = 'MATCH (n:NODE) WHERE n.name={name} RETURN n' batchbatchbatch
LICENSE
MIT