Skip to content
Node query builder for Cypher (tiny wrapper around string expressions)
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

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.


npm install cypher-query


cypher = require 'cypher-query'

query = cypher()
  .start('n = node(*)')
  .where(' = {name}', name: 'Joe')
  .where('n.age > {age}')
  .params(age: 22)
  .return('', 'n.age')

# Alternative API
query = cypher
  start: 'n = node(*)'
  where: [ ' = {name}', 'n.age > {age}' ]
  return: [ '', 'n.age' ]
  params: { name: 'Joe', age: 22 }

# Compile with toString() or compile()
query.toString() # START n=node(*)
                 # WHERE = {name} AND n.age > {age}
                 # RETURN, n.age

# Use params() to get all the collected params
query.params() # { name: 'Joe', age: 22 }

# Compile with compile(true) to embed the params into the string
query.compile(true) # START n=node(*)
                    # WHERE = 'Joe' and n.age > 22
                    # RETURN, n.age

With thingdom/node-neo4j

db = new neo4j.GraphDatabase
cypher = require 'cypher-query'

cypher().start('n=node(*)').execute db, (err, res) ->
cypher(start: 'n=node(*)').execute db, (err, res) ->

# Or install as db.builder()
db.builder().start('n=node(4)').execute (err, res) ->
db.builder(start: 'n=node(4)').execute (err, res) ->

# Or install globally to GraphDatabase's prototype

Utility methods

# Escape strings
cypher.escape 'hello " world!' # "hello "" world!"

# Escape identifiers
cypher.escape_identifier 'some ` identifier' # `some `` identifier`

# Build the MATCH pattern arrow string
cypher.pattern type: 'knows', direction: 'out' # -[:knows]->



Something went wrong with that request. Please try again.