appscot / sails-orientdb

OrientDB adapter for Waterline / Sails.js ORM
MIT License
25 stars 23 forks source link

Create edges for one-to-many #135

Closed fridaystreet closed 8 years ago

fridaystreet commented 8 years ago

Hi,

Just wondering if there is a technical reason why one-to-many (and I guess one-to-one for that matter) create links and not edges? We're creating a graph and really want all the relationships to benefit from the use of the graph.

Is anyone able to point me in the direction of where this is determined in sails-orientdb? I'd be happy to do a PR if I can make it optional?

Cheers Paul

dmarcelino commented 8 years ago

Hey @fridaystreet,

Edges in OrientDB describe many-to-many relationships and they map well with the concept of waterline's join table in many-to-many relationships. Doing it any other way would not only make it much more complex it would also not be "natural" as enforcing the one-to-many restriction would likely have to be done programatically.

So, the "technical" reason to use links in one-to-many relationships is actually so we have a way of using OrientDB's links.

If you are creating a graph my suggestion is to use many-to-many relationships and then programatically enforce the one-to-many restriction.