apoc
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -17,3 +17,4 @@ var fs = require('fs') | ||
var content = fs.readFileSync(acfFilePath).toString() | ||
content = content.trim().replace(/#.*/g, '') // remove comments | ||
content = content.trim().replace(/#.*/g, '') // remove # comments | ||
content = content.trim().replace(/\/\/.*/g, '') // remove // comments | ||
content = acfscript(content) // ACFscript | ||
@@ -25,2 +26,3 @@ content = parseInclusions(content, acfFilePath) | ||
content = content.replace(/;$/gm, '\n\n') | ||
content.split('\n\n').forEach(function (statement) { | ||
@@ -27,0 +29,0 @@ |
{ | ||
"name": "apoc", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "Making Cypher queries dynamic and powerful", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -6,7 +6,8 @@ Apoc | ||
* Comments using `#` | ||
* Comments using `#` or `//` | ||
* JavaScript code within backticks | ||
* Variables between %% (when used as a node module) | ||
* Multiple query statements in one file | ||
* Multiple query statements in a file | ||
* Ability to include other ACF files | ||
* Local variables in ACF files | ||
@@ -159,3 +160,3 @@ Apoc is not a mapper (ORM, ODM, ONM, OxM) of any kind, nor does it provide any "friendly" or "improved" transaction methods on top of the Neo4j REST API. It is just a tool for enhancing your experience with Cypher. You will still need to write your Cypher queries, but Apoc will make them more powerful and much easier to use. | ||
### Line breaks | ||
### Multiple query statements | ||
@@ -170,5 +171,13 @@ A single line break can be used to aesthetically break long query statements. Each line is understood as a part of the same query statement. | ||
A empty linebreak in an ACF file is used to separate query statements. All of the following are interpreted and executed as independent, separate queries. | ||
A semicolon at the end of the statement is used to separate query statements. | ||
``` | ||
CREATE (n:ApocTest { lang: 'hi', word: 'Naina' }) RETURN n; | ||
CREATE (n:ApocTest { lang: 'es', word: 'Ojo' }) RETURN n; | ||
CREATE (n:ApocTest { lang: 'it', word: 'Occhio' }) RETURN n; | ||
``` | ||
A empty linebreak can also be used in place of a semicolon to seprate query statements. All of the following are interpreted and executed as independent, separate queries. | ||
``` | ||
CREATE (n:ApocTest { lang: 'hi', word: 'Naina' }) RETURN n | ||
@@ -175,0 +184,0 @@ |
@@ -177,4 +177,4 @@ /* global describe, it, before, afterEach */ | ||
it('should execute multiline queries', function (done) { | ||
var query = apoc.query(acfPath('multiline.acf')) | ||
it('should execute multiple queries, separated with empty newlines', function (done) { | ||
var query = apoc.query(acfPath('newlines.acf')) | ||
query.exec(config).then(function (res) { | ||
@@ -195,2 +195,19 @@ expect('Aankh').to.equal(res[0].data[0].row[0].word) | ||
it('should execute multiple queries, separated with semicolons', function (done) { | ||
var query = apoc.query(acfPath('semicolons.acf')) | ||
query.exec(config).then(function (res) { | ||
expect('Aankh').to.equal(res[0].data[0].row[0].word) | ||
expect('Aankh').to.equal(res[1].data[0].row[0].word) | ||
expect('Kitab').to.equal(res[2].data[0].row[0].word) | ||
expect('Book').to.equal(res[2].data[0].row[2].word) | ||
expect('Naina').to.equal(res[3].data[0].row[0].word) | ||
expect('Eye').to.equal(res[3].data[0].row[2].word) | ||
expect('Aankh').to.equal(res[4].data[0].row[0].word) | ||
expect('Chakchu').to.equal(res[4].data[0].row[3].word) | ||
done() | ||
}, function (fail) { | ||
done(fail) | ||
}) | ||
}) | ||
it('should execute queries using included files', function (done) { | ||
@@ -197,0 +214,0 @@ var query = apoc.query(acfPath('inclusion.acf')) |
31842
33
561
302