Taking params via quercollection options
Is there a best way to do this or am i thinking about this wrong?
for context, i want to make a collection for session messages, on updates i'll probably end up using your writeBatch function to avoid refetches. however how would i go about the queryfn in an approach like this?
sorry if this is a newbie type of question, i usually like deep diving on docs but they aren't there yet and im sure we've got some pros in here
10 Replies
like-goldOP•2w ago
@samwillis tagging for visibility since we spoke ab this earlier
my immediate kind of thought here would be to make some sort of collection factory hehe
extended-salmon•2w ago
a factory function is a good way to do this
like-goldOP•2w ago
that was a LOT easier than i expected
wow
tanstack always a pleasure to work with
like-goldOP•6d ago
Here is my factory function

like-goldOP•6d ago
here is how i am handling events
like-goldOP•6d ago

like-goldOP•6d ago
the problem i am having is that these events are getting streamed in pretty fast (they are AI message streams) and the UI isn't really updating fast enough
should i be debouncing this or something or is there something that i am missing
like-goldOP•6d ago
i have a feeling that it is because i am storing a message with parts:

like-goldOP•6d ago
and i am updating the array in an object instead of directly updating something like a string
i guess my main question is, is it an issue with my data structure, or does tanstack Db batch rapid updates? @samwillis
extended-salmon•6d ago
We don't batch/throttle updates, if the ui can't keep up with the changes then throttling at the ui layer is likely best.
The alternative is to concatenate the tokens inside you api when writing to Postgres, or insert them inside a single transaction per time slide (the sync runs transactionally, you shouldn't see the ui update with part of a transaction).