You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks @CodeDredd for this great library, it is really well thought out and implemented.
I have an issue on ordering oneToMany relations. I have a Container model with oneToMany relations with Items (Container { @HasMany(() => Item, 'parentId') }). I want the user to be able to modify the order of items.
The solution that comes to mind is to add an "index" field to Item, and use that when querying the repo : useRepo(Container).with('items', (query) => query.sortBy('index'))
My problem with this solution is that it simplifies retrieving, but not updating (if I change the order, I have to update indexes on all Items), and conceptually, it puts the index information in the Item, while this is a container-level information.
Using a hasManyThrough could solve the "conceptual" issue, but at the cost of a higher retrieval and update complexity.
Does anyone have any insight/example on how to solve this issue?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Thanks @CodeDredd for this great library, it is really well thought out and implemented.
I have an issue on ordering oneToMany relations. I have a Container model with oneToMany relations with Items (
Container { @HasMany(() => Item, 'parentId') }
). I want the user to be able to modify the order of items.The solution that comes to mind is to add an "index" field to Item, and use that when querying the repo :
useRepo(Container).with('items', (query) => query.sortBy('index'))
My problem with this solution is that it simplifies retrieving, but not updating (if I change the order, I have to update indexes on all
Item
s), and conceptually, it puts theindex
information in the Item, while this is a container-level information.Using a
hasManyThrough
could solve the "conceptual" issue, but at the cost of a higher retrieval and update complexity.Does anyone have any insight/example on how to solve this issue?
Beta Was this translation helpful? Give feedback.
All reactions