Tree like relationships #308
-
Hi, I'm wondering what the best way to approach a recursive relationship entity. E.g. like a folder/files tree like structure? I have the following entity:
And the client code, which of course fetches the first level (and I am aware that I can include a pre-determined depth):
Without remult, I would have queried all records and then organised them hierarchically - I'm wondering if there's an elegant way of handling in remult, if if I would have to do the same? Many thanks |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
You can set the |
Beta Was this translation helpful? Give feedback.
-
If you eagerly load parent, does also parent.parent etc get loaded recursively ie. potentially a lot of queries? |
Beta Was this translation helpful? Give feedback.
-
Yes, if that becomes an issue you can selectively include - by setting
default included false
…On Sat, Dec 23, 2023 at 12:03 Toni ***@***.***> wrote:
If you eagerly load parent, does also parent.parent etc get loaded
recursively ie. potentially a lot of queries?
—
Reply to this email directly, view it on GitHub
<#308 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AD65PUZ7CYXMDLEY2RUA6PTYK2T6LAVCNFSM6AAAAABBABU4B6VHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM3TSMZTGE3TI>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
You can set the
defaultIncluded
of thetoMany
relations to true and works nice - see:https://codesandbox.io/p/devbox/demo-tree-shape-qvxkzv
(I had to set the defaultIncluded of the toOne relation to false for this