We've created javascript classes that wrap the nodes and rels we use to represent a graph. This is further wrapped with Nodes and Rels classes that represent subsets of the graph and offer fluent query functions to traverse the graph based on types, properties or just the availability of relations. github wikipedia
Here we preload eval with g, the Graph object holding the mock data we have examined elsewhere. github
Compare with our earlier Cypher Macros. **Note**: Shift-hover to align cases.
An Employee Details g.n('Employee', {name: 'H. R. Collins'}) .props('name')
All Employee Names g.n('Employee').props('name')
All Employees Named Flores g.n('Employee') .filter((type,props) => props['name'].includes('Flores')) .props('name')
All Employee Start Dates g.n('Employee').props('start')
All Employees Starting 2016 g.n('Employee').props('start') .filter(start => start > '2016')
All Managers of any Person or Thing g.n('Employee') .i('Manager').f().props()
Table of Projects with Managers table(g.n('Project').o('Manager'))
Table of Employees Managing Projects table(g.n('Employee').i('Manager').f('Project').o())
**Note**: The macro `table` is defined in the `fluent.html` file. See there also the definition of the macro `avg`.
One Project Node let nid = g.n('Project',{name:'Delta Xi'}).nids[0] g.nodes[nid]
All Project Names g.n('Project').props('name')
All Services in Delta Xi Project g.n('Project',{name:'Delta Xi'}) .i('Owner').f('Service').props()
All Employees on Delta PageRank Team g.n('Service',{name:'Delta PageRank'}) .o('Team').t('Employee').props('name')
Array of Statistics for Delta PageRank. let d = g.n('Service',{name:'Delta PageRank'}); let s = d.o('Traffic').t('Statistic'); [s.props('load'), s.props('ping')]
Avg Ping for all Statistic avg(g.n('Statistic').props('ping'))
Avg Load for all Statistic avg(g.n('Statistic').props('load'))
Avg Load for all Staging Service avg(g.n('Service') .o('Traffic',{environment:'staging'}) .t('Statistic').props('load'))
Avg Load for all Production Service avg(g.n('Service') .o('Traffic',{environment:'production'}) .t('Statistic').props('load'))
//wiki.ralfbarkow.ch/assets/pages/mock-graph-data/fluent.html HEIGHT 500