How to set up an API-backed permanent store? #1402
Unanswered
Nick-Motion
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
We're evaluating TanStack DB for a large application where we need to:
useLiveQueryAfter extensive testing and source code review, we've found that query collections cannot serve this use case due to three compounding issues:
1. Pagination is broken in on-demand mode (#820)
useLiveInfiniteQuerywithsyncMode: 'on-demand'doesn't implement cursor-based pagination. It appears to be designed only for moving a local window over a full dataset, rather than fetching pages on-demand.The proposed pagination docs in #1355 (Approach 2, marked "Recommended") won't work because of this.
2. Row eviction on unsubscribe deletes permanent data (#1309)
When a component unmounts,
subscription.unsubscribe()callsunloadSubset()for each loaded subset. The refcount inqueryToRows/rowToQueriesdrops to 0, andcleanupQueryInternaldeletes the rows from the collection viawrite({ type: 'delete' }).gcTimedoes not prevent this — it only controls TanStack Query's cache lifetime, not the DB collection's row lifecycle.3. Full State Sync prevents page accumulation
makeQueryResultHandlertreats eachqueryFnresult as complete state — items present in the old result but absent in the new result are deleted. This means anything written viawriteInsertgets wiped on refetch of pages.Questions:
Is there a planned path for "permanent collection" semantics — where rows survive unsubscribe and accumulate across paginated fetches?
What's the intended architecture for our use case? Using a Query Collection or Tanstack Query as the fetch/pagination layer and a separate local collection as the permanent store, and bridging them manually, creates a disconnect b/t the live query and the render - doesn't really work for making calls on-demand.
Versions:
Beta Was this translation helpful? Give feedback.
All reactions