Best practice suggestion: Should I avoid mapping over api data?
A lot of my useQuery hooks are mapping over api response to shape the data nicely for frontend consumption. My hunch is that I should generally avoid doing this and do the massaging in the select of a useLiveQuery or pure function instead of altering the data shape of whats going to the db.
Pls confirm/deny/refine my hunch 🙂
Example Before
Example After
2 Replies
conscious-sapphire•4w ago
Yeah exactly. You certainly can do this but the advantage of not doing it is that it's faster to have DB do the massaging and it's a lot more flexible as you can query data from the same collection to multiple places around your app w/o changing your queryFn
absent-sapphireOP•4w ago
🙇♂️