Vinelab / NeoEloquent

The Neo4j OGM for Laravel
MIT License
633 stars 197 forks source link

A way of querying based on relationship attributes. #361

Open xndbogdan opened 2 years ago

xndbogdan commented 2 years ago

Hi. I've checked the source code and documentation for a solution to my issue but was unable to. I am working on an app that allow users to have relationships between them. They can be friends, but also relatives. I'm managing this by having a "type" attribute on the relationship. Is there any way, for example, to query a certain Person A and fetch all of their sons/children, or only their friends?

Thank you!

Mulkave commented 2 years ago

Unfortunately this is not possible in the current version, and may be worked in the future. For the time being, the only way we work this out is by having two different relationship types (a method per relationship type between the models, or the model and itself). e.g.

(u1)-[:FRIENDS_WITH]->(u2) also have another relationship if both are needed (u1)-[:RELATED_TO]->(2) or (u1)-[:RELATIVE_OF]->(u2)