TanStackT
TanStack2mo ago
3 replies
sacred-emerald

Partial collection updates

Hi,

I would like to do partial collection updates for a subset of records. For example, I only want to refetch from the server the records with a foreignKeyId of 'xyz' which would subsequently update/insert the corresponding records in the collection. Of the 100 records in the collection, this might only fetch a handful of records.

For example, I want something like

myCollection.utils.refetch({ foreignKeyId: 'xyz' });

My current query function is like this:

queryFn: async () => getUsersForSessionsOwnedByUserServerFn(),


I think I need something like this:

// foreignKeyId might be null or a string
queryFn: async (foreignKeyId) => getUsersForSessionsOwnedByUserServerFn({ foreignKeyId }),


This would then update the records where the id matches.

Does this make sense? I know this is not the correct way but I think it's possible. What is the correct way to do this with tanstack DB?

Any help would be appreciated. Thank you.

JT
Was this page helpful?