Class: Neo4jConnector

Neo4jConnector

new Neo4jConnector(db)

Create an instance of Neo4jConnector. Examples: var neo4j = require('node-neo4j'); var acl = require('node-graph-acl'); var db = new neo4j('http://localhost:7474'); var connector = new acl.neo4jConnector(db);
This:
Parameters:
Name Type Description
db string The database connection string. Format: http://username:password@domain:port
Source:

Methods

_getParameters(object, callback)

Get object parameters after extracting all _* parameters. Examples: connector._getParameters(node, callback);
Parameters:
Name Type Description
object Object Object. Can be a node, a relationship, or any object.
callback function Callback called when finished.
Source:

addNodeLabels(nodeId, labels, callback)

Add labels to a node. Examples: connector.addNodeLabels(1, ['l1', 'l2'], callback);
Parameters:
Name Type Description
nodeId Number | String Node id.
labels Array Labels to add.
callback function Callback called when finished.
Source:

addNodeProperties(nodeId, properties, callback)

Add properties to a node. Examples: connector.addNodeProperties(1, {p1:'v1', p2:'v2'}, callback);
Parameters:
Name Type Description
nodeId String | Number Node id.
properties Object Properties to add.
callback function Callback called when finished.
Source:

addRelationship(from, to, type, properties, callback)

Create a relationship between two nodes. Properties can be added to the relationship. Examples: connector.addRelationship(1, 2, 'TYPE', {p1:'v1', p2:'v2'}, callback); connector.addRelationship(1, 2, 'TYPE', callback);
Parameters:
Name Type Description
from Number | String From Node id.
to Number | String To Node id.
type String Relationship Type.
properties Object Relationship properties.
callback function Callback called when finished.
Source:

addRelationshipProperties(relationshipId, properties, callback)

Add properties to a relationship. Examples: connector.addRelationshipProperties(1, {p1:'v1', p2:'v2'}, callback);
Parameters:
Name Type Description
relationshipId Number | String Relationship id.
properties Object Properties to add.
callback function Callback called when finished.
Source:

createNode(labels, properties, callback)

Create a node with given labels and properties. Examples: connector.createNode(callback); connector.createNode(['l1','l2'], callback); connector.createNode(['l1','l2'], {p1:'v1', p2:'v2'},, callback);
Parameters:
Name Type Description
labels Array Node labels.
properties Object Node properties.
callback function Callback called when finished.
Source:

deleteNode(nodeId, callback)

Delete an existing node. Examples: connector.deleteNode(1, callback);
Parameters:
Name Type Description
nodeId Number | String Node id.
callback function Callback called when finished.
Source:

existsNodeWithLabel(label, callback)

Check existence of Nodes with given label. Examples: connector.existsNodeWithLabel('Test', callback);
Parameters:
Name Type Description
label String Label to search.
callback function Callback called when finished.
Source:

existsNodeWithLabelsAndProperties(labels, properties, callback)

Check existence of Nodes with given labels and properties. Examples: connector.existsNodeWithLabelsAndProperties('Label', {p1: 'v1', p2: 'v2'}, callback); connector.existsNodeWithLabelsAndProperties(['Label1', 'Label2'], {p1: 'v1', p2: 'v2'}, callback);
Parameters:
Name Type Description
labels String | Array Labels to search.
properties Object Properties to search.
callback function Callback called when finished.
Source:

existsNodeWithProperties(properties, callback)

Check existence of Nodes with given properties. Examples: connector.existsNodeWithProperties({p1: 'v1', p2: 'v2'}, callback);
Parameters:
Name Type Description
properties Object Properties to search.
callback function Callback called when finished.
Source:

existsRelationshipsBetweenNodes(from, to, type, callback)

Check existence of Relationships between two nodes. Examples: connector.getRelationshipBetweenNodes(1, 2, callback); connector.getRelationshipBetweenNodes(1, 2, 'TYPE', callback);
Parameters:
Name Type Description
from Number | String From Node id.
to Number | String To Node id.
type String Relationship Type.
callback function Callback called when finished.
Source:

getNode(nodeId, callback)

Get a node. Examples: connector.getNode(1, callback);
Parameters:
Name Type Description
nodeId Number | String Node id.
callback function Callback called when finished.
Source:

getNodeLabels(nodeId, callback)

Get node labels. Examples: connector.getNodeLabels(1, callback);
Parameters:
Name Type Description
nodeId Number | String Node id.
callback function Callback called when finished.
Source:

getNodeProperties(nodeId, callback)

Get an existing node's properties. Examples: connector.getNodeProperties(1, callback);
Parameters:
Name Type Description
nodeId Number | String Node id.
callback function Callback called when finished.
Source:

getNodeRelationships(nodeId, options, callback)

Get a node relationships. Examples: var options = { types: ['TEST', ...] // optional direction: 'in' // optional, alternative 'out', defaults to 'all' } connector.getNodeRelationships(1, options, callback); connector.getNodeRelationships(1, {}, callback);
Parameters:
Name Type Description
nodeId Number | String Node id.
options String Type of relationship: 'in', 'out' or 'all' (Default). Optional.
callback function Callback called when finished.
Source:

getNodesWithLabel(label, callback)

Get Nodes with given label. Examples: connector.getNodesWithLabel('Test', callback);
Parameters:
Name Type Description
label String Label to search.
callback function Callback called when finished.
Source:

getNodesWithLabelsAndProperties(labels, properties, callback)

Get Nodes with given labels and properties. Examples: connector.getNodesWithLabelsAndProperties('Label', {p1: 'v1', p2: 'v2'}, callback); connector.getNodesWithLabelsAndProperties(['Label1', 'Label2'], {p1: 'v1', p2: 'v2'}, callback);
Parameters:
Name Type Description
labels String | Array Labels to search.
properties Object Properties to search.
callback function Callback called when finished.
Source:

getNodesWithProperties(properties, callback)

Get Nodes with given properties. Examples: connector.getNodesWithProperties({p1: 'v1', p2: 'v2'}, callback);
Parameters:
Name Type Description
properties Object Properties to search.
callback function Callback called when finished.
Source:

getRelationship(relationshipId, callback)

Get a relationship. Examples: connector.getRelationship(1, callback);
Parameters:
Name Type Description
relationshipId Number | String Relationship id.
callback function Callback called when finished.
Source:

getRelationshipProperties(relationshipId, callback)

Get a relationship properties. Examples: connector.getRelationshipProperties(1, callback);
Parameters:
Name Type Description
relationshipId Number | String Relationship id.
callback function Callback called when finished.
Source:

getRelationshipsBetweenNodes(from, to, type, callback)

Get Relationships between two nodes. Examples: connector.getRelationshipBetweenNodes(1, 2, callback); connector.getRelationshipBetweenNodes(1, 2, 'TYPE', callback);
Parameters:
Name Type Description
from Number | String From Node id.
to Number | String To Node id.
type String Relationship Type.
callback function Callback called when finished.
Source:

removeNodeLabels(nodeId, labels, callback)

Remove a label from a node. Examples: connector.removeNodeLabel(1, 'l1', callback); connector.removeNodeLabel(1, ['l1', 'l2'], callback);
Parameters:
Name Type Description
nodeId Number | String Node id.
labels String | Array Labels to remove.
callback function Callback called when finished.
Source:

removeNodeProperties(nodeId, properties, callback)

Removes properties from a node. Examples: connector.removeNodeProperties(1, ['p1', 'p2'], callback);
Parameters:
Name Type Description
nodeId Number | String Node id.
properties Object Properties to remove.
callback function Callback called when finished.
Source:

removeRelationship(relationshipId, callback)

Remove relationship. Examples: connector.removeRelationship(1, callback);
Parameters:
Name Type Description
relationshipId Number | String Relationship id.
callback function Callback called when finished.
Source:

removeRelationshipProperties(relationshipId, properties, callback)

Remove properties from a relationship. Examples: connector.removeRelationshipProperties(1, ['p1', 'p2'], callback);
Parameters:
Name Type Description
relationshipId Number | String Relationship id.
properties Object Properties to remove.
callback function Callback called when finished.
Source:

updateNode(nodeId, labels, properties, callback)

Update an existing node with given labels and properties. Note: All old properties and labels will be erased. Examples: connector.updateNode(1, callback); connector.updateNode(1, ['l1','l2'], callback); connector.updateNode(1, ['l1','l2'], {p1:'v1', p2:'v2'}, callback);
Parameters:
Name Type Description
nodeId Number | String Node id.
labels Array Node labels.
properties Object Node properties.
callback function Callback called when finished.
Source:

updateNodeProperties(nodeId, properties, callback)

Update properties of a node. Examples: connector.updateNodeProperties(1, {p1:'v1', p2:'v2'}, callback);
Parameters:
Name Type Description
nodeId String | Number Node id.
properties Object Properties to replace with.
callback function Callback called when finished.
Source:

updateRelationship(relationshipId, properties, callback)

Update properties of a relationship between two nodes. Examples: connector.updateRelationship(1, {p1:'v1', p2:'v2'}, callback);
Parameters:
Name Type Description
relationshipId Number | String Relationship id.
properties Object Relationship properties.
callback function Callback called when finished.
Source:

updateRelationshipProperties(relationshipId, properties, callback)

Update properties of a relationship. Examples: connector.updateRelationshipProperties(1, {p1:'v1', p2:'v2'}, callback);
Parameters:
Name Type Description
relationshipId Number | String Relationship ID.
properties Object Properties to replace with.
callback function Callback called when finished.
Source: