cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Cypher.js - graph db and Cypher query engine written in javascript

niclasko
Node Clone

Hi everyone!

I’d like to introduce my side project Cypher.js - a graph database and Cypher query engine written in javascript.

Have fun with it!

Thanks,
Niclas Kjäll-Ohlsson

3 REPLIES 3

niclasko
Node Clone

This was originally created to do further analysis in-browser of graph result sets from Neo4j backend.

I am also using it in several analytical web apps at work. This to do slicing, dicing and analysis of data in-browser for the web app.

A nice feature is that you can run Cypher directly on json data from http endpoints:

https://bit.ly/2zSQkzt

Cypher query from above link:

load json from "https://raw.githubusercontent.com/niclasko/niclasko.github.io/master/data/week_2018_38.json" as l
with collect(l) as rows
unwind rows as row
unwind row['values'] as v
with rows[0].datasource as datasource,
  row.key[0].en as series, collect({d: v[0], v: v[1]}) as c,
  stdev(v[1]) as series_std_dev,
  sum(v[1])/count(1) as series_avg
unwind c as e
return
  datasource,
  series,
  tostring(todate(e.d)) as date,
  e.v as val,
  (e.v-series_avg)/series_std_dev as val_z_score,
  series_std_dev,
  series_avg

And you can also run cypher directly on javascript objects (e.g. json) that you have already loaded in the web app

load json from your_javascript_object as d
return d

And also possible to load csv data from http endpoints:
https://bit.ly/2QoBSG9
Cypher query from link:

load csv with headers from "https://raw.githubusercontent.com/melaniewalsh/sample-social-network-datasets/master/sample-datasets/game-of-thrones/got-edges.csv" as l
merge (:Character{name:l.Source})
merge (:Character{name:l.Target})
with l
match (source:Character{name:l.Source}),
           (target:Character{name:l.Target})
merge (source)-[r:KNOWS{weight:l.Weight}]->(target)
return source, r, target

Note on above. Querying javascript objects only works when running Cypher.js in same thread as browser, i.e. not as a web worker. A web worker does not share scope with the browser main thread so cannot access variables from there

@niclasko This is great! Have been wondering if there was something like this for awhile, glad I stumbled upon this. 

What version of Cypher is this compatible with? Are there any limitations or APIs that aren't implemented?