bigcompany / resources

a collection of useful resources
https://github.com/bigcompany/resource
79 stars 15 forks source link

create [relationship] resource #58

Open erobit opened 11 years ago

erobit commented 11 years ago

The ability to relate resources (directionally) using an expressive library (not just parent/child) that can eventually persist to graph databases. A query syntax would also be required to traverse relationships depending on persistence mode.

http://docs.neo4j.org/chunked/milestone/graphdb-neo4j-relationships.html http://aseemk.com/talks/neo4j-with-nodejs#/

var rel = resource.use('relationship');

// creates bidirectional link ? rel.create(user, creature, 'friend');

Note: third param could be options to define type of relationship / schema along with directionality and make the relationships introspectable - easily graphed for doc generation and visual navigation uis.

// query rel.find(user, 'friend');

Ideally more params could be added to support a detailed query syntax - start node, other node, depth, etc... and could utilize query engines for the different persistence adapters.

I don't know exactly how this should work in terms of IOC, if it makes more sense for it to be core resource functionality, or sit on top. It should be easy enough to extend the resource with methods like the persistence resource does (CRUD) to allow for orm style queries of relationships.

user.rel.create() user.rel.find()

ahdinosaur commented 11 years ago

i think the best way to integrate graphs into big is through compatibility with http://json-ld.org/spec/latest/json-ld/.