Progressive Cypher query builder API. Represnts the query as an object (a tiny wrapper around string expressions), allowing to pass it around and mutate it.
Written in CoffeeScript.
This is alpha quality software. It has not been throughtfully tested.
Install
npm install cypher-query
Usage
cypher = require 'cypher-query' query = cypher start'n = node(*)' where'n.name = {name}'name: 'Joe' where'n.age > {age}' paramsage: 22 return'n.email''n.age' # Alternative API query = cypher start: 'n = node(*)' where: 'n.name = {name}''n.age > {age}' return: 'n.email''n.age' params: name: 'Joe'age: 22 # Compile with toString() or compile() querytoString # START n=node(*) # WHERE n.name = {name} AND n.age > {age} # RETURN n.email, n.age # Use params() to get all the collected params queryparams # { name: 'Joe', age: 22 } # Compile with compile(true) to embed the params into the string querycompiletrue # START n=node(*) # WHERE n.name = 'Joe' and n.age > 22 # RETURN n.email, n.age
thingdom/node-neo4j
Withdb = cypher = require 'cypher-query' cypherstart'n=node(*)'execute dbcypherstart: 'n=node(*)'execute db # Or install as db.builder() cypherinstalldbdbbuilderstart'n=node(4)'execute dbbuilderstart: 'n=node(4)'execute # Or install globally to GraphDatabase's prototype cypherinstall
Utility methods
# Escape strings cypherescape 'hello " world!' # "hello "" world!" # Escape identifiers cypherescape_identifier 'some ` identifier' # `some `` identifier` # Build the MATCH pattern arrow string cypherpattern type: 'knows'direction: 'out' # -[:knows]->
License
MIT