sails.js - Waterline Edges associations -
i prepared model contains 2 vertices , 1 edge between them, v1, v2 , e1, while v1 instance or vertex of class a, , v2 vertex of class b. e1 instance of class e. wanted prepare schema in waterline kind of relation , schema looks this:
identity:'a', connection:'ex1', attributes:{ title:'string', r : {collection:'b', through:'e', via:'a'} } identity:'a', connection:'ex1', attributes:{ title:'string', r : {collection:'a', through:'e', via:'b'} }
while if use schema map orientdb fields shows collection:'b' linkset in class. want relate them via edges. there way skip mentioning collections , build relation map @rid of edge e1 out or in field of these classes needed?
xeeb, don't mention waterline adapter orientdb using (there @ least 3). i'll assume it's waterline-orientdb.
in schema example, defining "many-to-many through" association missing (or didn't share) definition of "through" model (example).
finally, simplest way build relations between vertexes using edges use "many-to-many" associations. can following code snippet based on own example:
// model { tablename : 'a', identity : 'a', connection : 'ex1', attributes : { title : 'string', r : { collection : 'b', via : 'r', dominant : true } } } // model b { tablename : 'b', identity : 'b', connection : 'ex1', attributes : { title : 'string', r : { collection : 'a', via : 'r' } } }
a full "many-to-many" association working example at: https://github.com/appscot/waterline-orientdb/blob/master/example/associations/many-to-many.js
update: waterline-orientdb named sails-orientdb.
Comments
Post a Comment