Comparing version 0.10.0 to 0.11.0
{ | ||
"name": "decypher", | ||
"version": "0.10.0", | ||
"version": "0.11.0", | ||
"description": "A handful of cypher utilities for Node.js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
22
query.js
@@ -12,2 +12,3 @@ /** | ||
relationshipPattern = helpers.relationshipPattern, | ||
escapeLiteralMap = helpers.escapeLiteralMap, | ||
Expression = require('./expression.js'); | ||
@@ -17,2 +18,4 @@ | ||
var INTERPOLATION_REGEX = /{([\w\d]+)}/g; | ||
/** | ||
@@ -107,2 +110,21 @@ * Helpers. | ||
// Interpolating the parameters within the query | ||
Query.prototype.interpolate = function() { | ||
var string = this.compile(), | ||
params = this.params(); | ||
return string.replace(INTERPOLATION_REGEX, function(match, identifier) { | ||
if (params.hasOwnProperty(identifier)) { | ||
var value = params[identifier]; | ||
if (typeof value === 'object' && !Array.isArray(value)) | ||
return escapeLiteralMap(value); | ||
else | ||
return JSON.stringify(value); | ||
} | ||
return match; | ||
}); | ||
}; | ||
// Attaching a method to the prototype for each statement | ||
@@ -109,0 +131,0 @@ STATEMENTS.concat(['']).forEach(function(statement) { |
@@ -156,2 +156,9 @@ [![Build Status](https://travis-ci.org/Yomguithereal/decypher.svg)](https://travis-ci.org/Yomguithereal/decypher) | ||
// You can also alternatively interpolate the params into the query | ||
// (Useful for debugging but unsafe!!!) | ||
cypher.interpolate(); | ||
>>> `MATCH (n:Node) | ||
WHERE n.title = "The best title" | ||
RETURN n;` | ||
// Note that multi words statements like `ORDER BY` have to be written in camel-case: | ||
@@ -158,0 +165,0 @@ cypher.orderBy('n.title'); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33383
747
439