floor
floor copied to clipboard
Relationship with entities and queries
Hi,
is it possible to do into the DAO a join with 2 entities who are link with foreign key ? In order to have the parent and a list of children into the parent object ?
And if we have always the parent and a list of children in memories, can we use the @insert in order to insert into Moor on the 2 tables (like cascade in Doctrine) ?
If yes, do you have example of this 2 questions ?
Thanks
is it possible to do into the DAO a join with 2 entities who are link with foreign key ? In order to have the parent and a list of children into the parent object ?
Joined return values (e.g. parent with children in one row) are currently only partly supported. Can a database view help you in this situation? Database views fully support JOIN clauses.
And if we have always the parent and a list of children in memories, can we use the @insert in order to insert into Moor on the 2 tables (like cascade in Doctrine) ?
If both floor and moor databases access the same database file, there should technically not be a problem with that. I have never tried that myself though.
This feature would be amazing, I’m actually currently working on it. Similar to what django offers.
Take a look https://github.com/vitusortner/floor/discussions/492
Joins as a feature can be achieved through multiple means:
- through
@Relation
(#47) - through returning arbitrary objects in
@Query
s (#94) - through assembling views for the returned objects (already implemented, see https://vitusortner.github.io/floor/database-views/.)
But as this question isn't asked for the first time, I think we should improve the documentation on views, to include at least an example for joins.