cypher-query

Query builder for Cypher (tiny wrapper around string expressions)

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 used and tested.

npm install cypher-query

cypher = require 'cypher-query'
 
query = cypher()
  .start('node(*) as n')
  .where('n.name = {name}'name: 'Joe')
  .where('n.age > {age}'age: 22)
  .return('n.email''n.age')
 
# Alternative API 
query = cypher
  start: 'node(*) as n'
  where: [ 'n.name = {name}''n.age > {age}' ]
  return: [ 'n.email''n.age' ]
  params: { name: 'Joe'age: 123 }
 
# Compile with toString() 
query.toString() # START node(*) as n 
                 # WHERE n.name = 'Joe' AND n.age > 22 
                 # RETURN n.email 

With thingdom/node-neo4j

db = new neo4j.GraphDatabase
 
cypher().start('node(*) as n').return('n').execute db(err, res) ->
 
# Or install as db.builder() 
cypher.install(db)
db.builder().return(..).execute (err, res) ->
 
# Or install globally to GraphDatabase prototype 
cypher.install()

MIT