-
Notifications
You must be signed in to change notification settings - Fork 30
feat: collection enrichment #1641
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## main #1641 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 56 56
Lines 1824 1830 +6
Branches 423 425 +2
=========================================
+ Hits 1824 1830 +6 ☔ View full report in Codecov by Sentry. |
Bundle ReportChanges will increase total bundle size by 1.98kB (0.03%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: @signaldb/syncAssets Changed:
view changes for bundle: @signaldb/coreAssets Changed:
|
Thank you for doing this. Such a good feature! |
Hi @signalize, that's a really neat idea to solve the N+1 problem! 🙂 Also, this is quite similar to the existing ´transform´ functionality, so I’m a bit unsure about the naming. Maybe something like ´transformAll´ would better capture the intent? I definitely see the value of this feature, but I'm not entirely sure how it should be implemented. Perhaps we could approach it more generally, like a hooking system, and introduce hooks such as ´beforeFetch´, ´afterFetch´, etc. (since ´enrichCollection´ essentially hooks into query results and modifies them). This also seems to have some parallels to your other PR, #1618 |
# Conflicts: # packages/base/core/CHANGELOG.md
@maxnowack For now, i changed in to transformAll and improved the return type. Please let me know what you think 😃 |
@maxnowack FYI, the changes from the pull request #1691 negative effects the 'transformAll' benchmark. When i decrease the amount of inserts to 1000 instead of 10000 it will work... |
@signalize thanks for the hint! I addressed this issue in #1717 🙂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the typings for this feature are still not as good as they should be. The return type of the Cursor
methods should be completely generic and inferred by the result of transformAll
(like it is for the regular item transform
). In general it would be good if the implementation is more similar to the implementation of the existing transform
.
# Conflicts: # packages/base/core/CHANGELOG.md
# Conflicts: # packages/base/core/CHANGELOG.md # packages/base/core/src/Collection/index.ts
Solution to the "N+1 problem" when dealing with related data. By implementing the enrichCollection option within the Collection definition you can reduce the number of queries required.
changes: