cypher-query
Query builder for Cypher (tiny wrapper around string expressions)
Last updated 7 years ago by nadav .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install cypher-query 
SYNC missed versions from official npm registry.

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}')
  .params(age: 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()
query.toString() # START n=node(*)
                 # WHERE n.name = {name} AND n.age > {age}
                 # RETURN n.email, 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 n.name = 'Joe' and n.age > 22
                    # RETURN n.email, 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()
cypher.install(db)
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
cypher.install()

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]->

License

MIT

Current Tags

  • 0.0.12                                ...           latest (5 years ago)

9 Versions

  • 0.0.12                                ...           5 years ago
  • 0.0.11                                ...           7 years ago
  • 0.0.10                                ...           7 years ago
  • 0.0.9                                ...           7 years ago
  • 0.0.4                                ...           7 years ago
  • 0.0.3                                ...           7 years ago
  • 0.0.2                                ...           7 years ago
  • 0.0.1                                ...           7 years ago
  • 0.0.0                                ...           7 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 0
Last Month 3
Dependencies (0)
None
Dev Dependencies (2)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |