Socket
Socket
Sign inDemoInstall

apoc

Package Overview
Dependencies
37
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.1 to 2.1.0

lib/acfscript-parser.js

2

lib/acf-reader.js
var fs = require('fs')
var path = require('path')
var parseInclusions = require(__dirname + '/inclusion-parser.js')
var acfscript = require(__dirname + '/acfscript-parser.js')
var template = require(__dirname + '/template.js')

@@ -17,2 +18,3 @@ var jscode = require(__dirname + '/jscode.js')

content = content.trim().replace(/#.*/g, '') // remove comments
content = acfscript(content) // ACFscript
content = parseInclusions(content, acfFilePath)

@@ -19,0 +21,0 @@

6

lib/commands/query.js

@@ -6,3 +6,4 @@ var debug = require('debug')('apoc:query')

var util = require(__dirname + '/../util.js')
var getStatements = require(__dirname + '/../acf-reader.js')
var readAcf = require(__dirname + '/../acf-reader.js')
var acfscript = require(__dirname + '/../acfscript-parser.js')
var template = require(__dirname + '/../template.js')

@@ -28,6 +29,7 @@ var jscode = require(__dirname + '/../jscode.js')

if (acfQuery) {
getStatements(input, vars, context).forEach(function (statement) {
readAcf(input, vars, context).forEach(function (statement) {
statements.push({ statement: statement })
})
} else {
input = acfscript(input) // ACFscript
if (vars) input = template(input, vars) // template

@@ -34,0 +36,0 @@ input = jscode(input, context) // js code

{
"name": "apoc",
"version": "2.0.1",
"version": "2.1.0",
"description": "Making Cypher queries dynamic and powerful",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -143,2 +143,17 @@ Apoc

### ACF variables
You can define variables in the ACF file using the `var` keyword. The value of the variable can also be a JavaScript expression.
```
var label = ApocTest
var floor=`Math.floor(22/7)`
CREATE(a:%label% { pi: `22/7`, floor: %floor% }) RETURN a
CREATE(b:%label% { label: "%label%", floor: %floor% }) RETURN b
```
ACF variables take precedence over those specified by the variables query parameter.
### Line breaks

@@ -145,0 +160,0 @@

@@ -127,3 +127,3 @@ /* global describe, it, before, afterEach */

describe('acf', function () {
describe('acf file', function () {

@@ -211,2 +211,19 @@ it('should execute query', function (done) {

describe('acfscript', function () {
it('should parse variables', function (done) {
var query = apoc.query(acfPath('acfscript.acf'))
query.exec(config).then(function (res) {
expect(22 / 7).to.equal(res[0].data[0].row[0].pi)
expect(Math.floor(22 / 7)).to.equal(res[0].data[0].row[0].floor)
expect('ApocTest').to.equal(res[1].data[0].row[0].label)
expect(Math.floor(22 / 7)).to.equal(res[1].data[0].row[0].floor)
done()
}, function (fail) {
done(fail)
})
})
})
})

@@ -213,0 +230,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc