Cypher Macros

We wonder, can we write a series of functions that capture the semantics of cypher without actually Parsing Cypher?

One html script defines the macros, collects query definitions from this page, presents them as a clickable list that runs a query and presents the result. github

n for node: subsets the list of nodes.

i for inward, o for outward: access relations from nodes.

w for where: further subset nodes with predicate.

p for property: select one property from each node.

a for arithmetic: applies avg to numeric properties.

We now test the translations we have already completed. Edit or add Code items for more. See Cypher in Javascript

An Employee Details n('Employee','H. R. Collins')

All Employee Names p(n('Employee'))

All Employees named Flores p(w(n('Employee'), props =>'Flores')))

All Employee Start Dates p(n('Employee'),'start')

All Employees Starting 2016 p(w(n('Employee'), props => props.start > '2016'))

All Managers of any Kind p(i(n('Employee'), 'Manager'))

All Project Managers p(i(n('Employee'), 'Manager', n('Project')))

A Project Detail n('Project','Delta Xi')

All Project Names p(n('Project'))

All Services in Delta Xi Project p(o(n('Service'),'Owner', n('Project','Delta Xi')))

All Employees on Delta PageRank Team p(i(n('Employee'),'Team', n('Service','Delta PageRank')))

All Statistics for Delta PageRank. i(n('Statistic'),'Traffic', n('Service','Delta PageRank'))

Avg Load for all Statistic a(p(n('Statistic'),'load'))

Avg Ping for all Statistic a(p(n('Statistic'),'ping'))

Uh oh. Can't select on Environment property of Traffic.

Avg Load for all Production Service p(i(n('Statistic'), 'Traffic', n('Service')),'load')

// HEIGHT 500