forked from svenmuellerssen/Neo4JQuery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
package.json
executable file
·38 lines (38 loc) · 15.1 KB
/
package.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{
"name": "neo4jquery",
"version": "0.1.2",
"description": "Module that handles neo4j database cypher syntax as method calls.",
"main": "index.js",
"scripts": {
"test": "mocha"
},
"dependencies": {
"underscore": "1.6.0",
"async": "0.9.0"
},
"repository": {
"type": "git",
"url": "https://github.com/svenmuellerssen/Neo4JQuery.git"
},
"keywords": [
"neo4jquery",
"neo4j",
"graph database",
"cypher",
"query"
],
"author": {
"name": "Sven Mueller",
"email": "[email protected]"
},
"license": "LGPL",
"bugs": {
"url": "https://github.com/svenmuellerssen/Neo4JQuery/issues"
},
"readme": "# Neo4jQuery\nTool that handles cypher syntax as method calls.\n\n# What is Neo4jQuery?\n˙Neo4JQuery˙ is an implementation made to to use the query language 'Cypher' of the graph database ˙Neo4J˙ only.\n\n#Why Neo4jQuery\nThe library provides the strength of Cypher to use batch functionality\nlike multiple matches and merges and creating relationships in one query.\n\nIt is also made to be more like programming a Cypher query than have lots of Cypher strings in the code which\n could be confusing.\n\nTherefor you have lots of methods available in the query builder object which can be chained and\nis looking like a real cypher command in the end.\n\n# How to use\n1. Download repository into a library folder (later it should be a npm module).\n2. Install the module `underscore` via __npm install underscore__.\n3. Install the driver module like `seraph` via __npm install seraph__.\n4. Import both, `seraph` and `Neo4jQuery`, with 'require' and connect to your Neo4J graph database.\n\n__Quick example to get connection__\n```javascript\nvar seraph = require(\"seraph\")({\n server: \"http://127.0.0.1:7474\",\n endpoint: \"/data/graph.db\",\n user: \"testuser\",\n pass: \"testpass\"\n })\n , graph = require(\"neo4jquery\").setConnection(seraph);\n\n```\n\n# Documentation\n\n## Graph\n<a name=\"setConnection\" />\n### setConnection(connection)\n\nSets a driver which is connected to a Neo4J database.\nThe only requirement is that the driver implements a method called 'query'.\n\n__Arguments__\n\n* `connection` (object) - A driver with a connection to a Neo4J database\n\n__Example__\n\n```javascript\nvar graph = require(\"neo4jquery\").setConnection(<driver object>);\n```\n\n<a name=\"query\" />\n### Query(query, parameters, callback)\n\nExecutes a passed-in query directly. Using parameters for parameterized cypher queries.\n\n__Arguments__\n\n* `query` (string) - The cypher query to be executed.\n* `parameters` (object) - Parameters for parameterized queries.\n* `callback` (function) - Callback function with parameters 'error' and 'array list'.\n\n__Example__\n\n```javascript\nvar graph = require(\"neo4jquery\").setConnection(<driver object>)\n , query = \"MATCH (n:Node {field1: {v1}})-[r1:IS_LABEL]-(n2:Node2 {field2: {v2}}) RETURN n\"\n , parameters = {v1: \"value1\", v2: \"value2\"}\n\n graph.Query(query, parameters, function(err, list) {\n if (err || void 0 === list) {\n callback(err, void 0);\n } else {\n // some stuff here with list\n var user = list[0];\n }\n });\n```\n\n<a name=\"builder\" />\n### Builder()\n\nGet the Cypher builder object.\n\n__Arguments__\n\n* No arguments\n\n__Example__\n\n```javascript\nvar graph = require(\"neo4jquery\").setConnection(<driver object>)\n , builder = graph.Builder();\n\n```\n\n<a name=\"run\" />\n### run(builder, cached, callback)\n\nSets conditions to find specific nodes or relationships.\n\n__Arguments__\n\n* `builder` (Builder) - Cypher query builder object.\n* `cached` (bool) - Flag to use the last cypher query.\n* `callback` (function) - The callback function. Parameter of this function are first an error object and second an array as resultset.\n\n__Example__\n\n```javascript\nvar graph = require(\"neo4jquery\").setConnection(<driver object>)\n , builder = graph.Builder();\n\n builder\n .reset()\n .Match('n', 'User')\n .Where(\"n.username={username} and n.password={password}\", {username: \"testuser\", password: \"testpass\"})\n\n graph.run(builder, false, function(err, list) {\n if (err || void 0 === list) {\n callback(err, void 0);\n } else {\n // some stuff here with list\n var user = list[0];\n }\n });\n```\n\n<a name=\"execute\" />\n### execute(options)\n\nExecutes the query and returns result set.\n\n__Arguments__\n\n* `options` (Object) - An config object with needed settings.\n- `builder` (Builder) - The Cypher query builder you created the query with.\n- `cached` (boolean) - Flag set to false for default. Set to true Neo4JQuery will use the last cached query for execution.\n- `aliases` (Object) - Setting with aliases for the returned result placeholder\n- `success` (function) - Callback function used if query was successful.\n- `error` (function) - Callback function used if query was unsuccessful.\n\n__Example__\n\n```javascript\nvar graph = require(\"neo4jquery\").setConnection(<driver object>)\n , builder = graph.Builder();\n\n builder\n .reset()\n .Match('u', 'User', {username: \"testuser\", password: \"testpass\"});\n\n graph.execute({\n builder: builder,\n cached: false,\n aliases: {\n u: 'user'\n },\n success: function(results) {...},\n error: function(err) {...}\n });\n```\n\n## Cypher Builder\n\n<a name=\"reset\" />\n### reset()\n\nResets the builder object (inclusive cached query). Should be used to be as first method in the chain when you get the builder object.\n\n__Arguments__\n\n* No arguments\n\n__Example__\n\n```javascript\nvar graph = require(\"neo4jquery\").setConnection(<driver object>)\n , builder = graph.Builder();\n\n builder.reset();\n```\n\n<a name=\"match\" />\n### Match(placeholder, label, optional, parameters)\nMatches data specified through labels and parameters and bound to the placeholder.\n\n__Arguments__\n\n* `placeholder` (string) - The placeholder of the node or relationship.\n* `label` (string) - The labels which are assigned to nodes.\n* `optional` (boolean) - Flag to use 'OPTIONAL MATCH'. Default is `false`.\n* `parameters` (object) - Parameters to filter nodes.\n\n__Example__\n\n```javascript\nvar graph = require(\"neo4jquery\").setConnection(<driver object>)\n , builder = graph.Builder();\n\n builder\n .reset()\n .Match('n', 'node', false, {field1: '...', field2: '...'});\n\n graph.execute({\n builder: builder,\n cached: false,\n aliases: {\n n: 'node'\n },\n success: function(results) {...},\n error: function(err) {...}\n });\n```\n\n<a name=\"optionalmatch\" />\n### OptionalMatch(placeholder, label, parameters)\nMatches data specified through labels and parameters and bound to the placeholder.\nIf there is no information found the placeholder will be null.\n\n__Arguments__\n\n* `placeholder` (string) - The placeholder of the node or relationship.\n* `label` (string) - The labels which are assigned to nodes.\n* `optional` (boolean) - Flag to use 'OPTIONAL MATCH'. Default is `false`.\n* `parameters` (object) - Parameters to filter nodes.\n\n__Example__\n\n```javascript\nvar graph = require(\"neo4jquery\").setConnection(<driver object>)\n , builder = graph.Builder();\n\n builder\n .reset()\n .OptionalMatch('n', 'node', {field1: '...', field2: '...'});\n\n graph.execute({\n builder: builder,\n cached: false,\n aliases: {\n n: 'node'\n },\n success: function(results) {...},\n error: function(err) {...}\n });\n```\n\n<a name=\"merge\" />\n### Merge(placeholder, label, parameters)\nTry to create and insert new node with given parameters and label.\n\n__Arguments__\n\n* `placeholder` (string) - The placeholder of the node.\n* `label` (string) - The labels which are assigned to the node.\n* `parameters` (object) - Parameters of the node.\n\n__Example__\n\n```javascript\nvar graph = require(\"neo4jquery\").setConnection(<driver object>)\n , builder = graph.Builder();\n\n builder\n .reset()\n .Merge('u', 'User', {field1: '...', field2: '...', createdAt: 120987654321});\n\n graph.execute({\n builder: builder,\n cached: false,\n aliases: {\n u: 'user'\n },\n success: function(results) {...},\n error: function(err) {...}\n });\n```\n\n<a name=\"mergerelationship\" />\n### MergeRelationShip(nodes, placeholder, label, parameters)\nTry connect two nodes with a relationship with given information.\n\n\n__Arguments__\n\n* `nodes` (array) - The placeholder of the nodes which has to be connected with each other.\n* `placeholder` (string) - The placeholder of the relationship.\n* `label` (string) - The labels which are assigned to the relationship.\n* `parameters` (object) - Parameters of the relationship.\n\n__Example__\n\n```javascript\n// Here the first value in the nodes array points to the second value \n// via relationship 'ASSIGNED_WITH_EACH_OTHER'!\nvar graph = require(\"neo4jquery\").setConnection(<driver object>)\n , builder = graph.Builder();\n\n builder\n .reset()\n .Match('u', 'User', false, {field1: ..., field2: ...})\n .With(['u'])\n .Merge('n', 'Node', false, {field1: '...', field2: '...', createdAt: 120987654321})\n .With(['u', 'n'])\n .MergeRelationShip(['n', 'u'], 'r', 'ASSIGNED_WITH_EACH_OTHER', {field1: '...', field2: '...'});\n\n graph.execute({\n builder: builder,\n cached: false,\n aliases: {\n u: 'user',\n n: 'node',\n r: 'relation'\n },\n success: function(results) {...},\n error: function(err) {...}\n });\n```\n\n<a name=\"oncreate\" />\n### onCreate(command)\nEvent used with _Merge_ to be executed if _Merge_ creates a new node/relationship.\n\n\n__Arguments__\n\n* `command` (string) - The command like _SET_ followed by what to do.\n\n__Example__\n\n```javascript\nvar graph = require(\"neo4jquery\").setConnection(<driver object>)\n , builder = graph.Builder();\n\n builder\n .reset()\n .Merge('u', 'User', {field1: ..., field2: ...})\n .relate('r1', 'GUESSED_RELATIONSHIP')\n .toNode('n', 'Note', {field3: ..., field4: ...})\n .onCreate('SET u.createdAt=timestamp(), n.createdAt=timestamp()');\n\n graph.execute({\n builder: builder,\n cached: false,\n aliases: {\n u: 'user',\n n: 'node'\n },\n success: function(results) {...},\n error: function(err) {...}\n });\n```\n\n<a name=\"onmatch\" />\n### onMatch(command)\nEvent used with _Merge_ to be executed if _Merge_ matches a node.\n\n\n__Arguments__\n\n* `command` (string) - The command like _SET_ followed by what to do.\n\n__Example__\n\n```javascript\nvar graph = require(\"neo4jquery\").setConnection(<driver object>)\n , builder = graph.Builder();\n\n builder\n .reset()\n .Merge('u', 'User', {field1: ..., field2: ...})\n .relate('r1', 'GUESSED_RELATIONSHIP')\n .toNode('n', 'Note', {field3: ..., field4: ...})\n .onMatch('SET u.visited=timestamp(), n.visited=timestamp()');\n\n graph.execute({\n builder: builder,\n cached: false,\n aliases: {\n u: 'user',\n n: 'node'\n },\n success: function(results) {...},\n error: function(err) {...}\n });\n```\n\n<a name=\"delete\" />\n### Delete(placeholder)\nDeletes all the given nodes/relationships.\nPlease take care of the order of relationships and nodes you want to remove.\n\n__Arguments__\n\n* `placeholder` (string|array) - The placeholder of node/nodes to be deleted.\n\n__Example__\n\n```javascript\nvar graph = require(\"neo4jquery\").setConnection(<driver object>)\n , builder = graph.Builder();\n\n builder\n .reset()\n .Match('u', 'User', {...})\n .relate('r1', 'RELATIONSHIP', {...})\n .toNode('u2', 'User', {...})\n .Delete(['r1', 'u', 'u2']);\n\n graph.execute({\n builder: builder,\n success: function(results) {...},\n error: function(err) {...}\n });\n```\n\n<a name=\"with\" />\n### With(placeholders)\nSets a driver which is connected to a Neo4j database. The only requirement is that the driver implements a method called 'query'.\n\n__Arguments__\n\n* `placeholders` (array) - An array with all placeholders which have to be connected with next cypher command.\n\n__Example__\n\n```javascript\nvar graph = require(\"neo4jquery\").setConnection(<driver object>)\n , builder = graph.Builder();\n\n builder\n .reset()\n .Match('u', 'User', {username: 'neo4jqueryuser', password: 'password'})\n .With(['u'])\n .MergeRelationShip(['u'], 'r', 'ASSIGNED_WITH_EACH_OTHER', {field1: '...', field2: '...'});\n\n graph.execute({\n builder: builder,\n cached: false,\n aliases: {\n u: 'user',\n r: 'relation'\n },\n success: function(results) {...},\n error: function(err) {...}\n });\n```\n\n<a name=\"where\" />\n### Where(placeholder, parameter)\n\nSets conditions to find specific nodes or relationships.\n\n__Arguments__\n\n* `string` (string) - The conditions to filter nodes and/or relationships.\n* `parameter` (object) - The parameters for prepared cypher statements provided by the NodeJS driver.\n\n__Example__\n\n```javascript\nvar graph = require(\"neo4jquery\").setConnection(<driver object>)\n , builder = graph.Builder();\n\n builder\n .reset()\n .Match('u', 'User')\n .Where(\"u.username={username} and u.password={password}\", {username: 'testuser', password: 'password'});\n\n graph.execute({\n builder: builder,\n cached: false,\n aliases: {\n u: 'user'\n },\n success: function(results) {...},\n error: function(err) {...}\n });\n```\n\n<a name=\"set\" />\n### Set(placeholder, parameter)\n\nSets given properties to a node or relationship.\n\n__Arguments__\n\n* `placeholder` (string) - The placeholder of the node or relationship.\n* `parameter` (object) - All parameters to be set as properties in the node or relationship.\n\n__Example__\n\n```javascript\nvar graph = require(\"neo4jquery\").setConnection(<driver object>)\n , builder = graph.Builder();\n\n builder\n .reset()\n .Match('u', 'User')\n .Where(\"u.username={username} and u.password={password}\", {username: 'testuser', password: 'password'})\n .Set('u', {createdAt: 1440360134452, updatedAt: 1440360134452});\n\n graph.execute({\n builder: builder,\n cached: false,\n aliases: {\n u: 'user'\n },\n success: function(results) {...},\n error: function(err) {...}\n });\n```\n\n<a name=\"foreachcondition\" />\n### ForeachCondition(condition, query)\n\nAdds a cypher foreach loop to the query to update the nodes in a list.\n\n__Arguments__\n\n* `condition` (string) - The condition to iterate over a list of nodes.\n* `query` (string) - The update command.\n\n__Example__\n\n```javascript\nvar graph = require(\"neo4jquery\").setConnection(<driver object>)\n , builder = graph.Builder();\n\n builder\n .reset()\n .Match('u', 'User')\n .Where(\"u.updatedAt > {timestamp}\", {timestamp: new Date().getTime() - 3600})\n .ForeachCondition('user IN u', 'SET u.visited=true');\n\n graph.execute({\n builder: builder,\n cached: false,\n aliases: {\n u: 'user'\n },\n success: function(results) {...},\n error: function(err) {...}\n });\n```\n\n",
"readmeFilename": "README.md",
"gitHead": "3ce96c4aed74475d3ccb81533af891ab66f60331",
"_id": "[email protected]",
"_shasum": "bb0b9940f833b67057c4e77e515203307d3c2cc6",
"_from": "neo4jquery@*"
}