CasperLeerink
CasperLeerink
Explore posts from servers
TtRPC
Created by CasperLeerink on 10/10/2024 in #❓-help
Keep old data when changing trpc procedure inputs
Hi! I was wondering if anyone has a best practice for preventing a flash of no data when changing inputs for a certain trpc procedure using tanstack query. My usecase is a leaflet map where the data it fetches changes when changing the zoom or position of the map. But I still want to show the old data when I am panning the map for example. I am currently using something like this where navigate triggers new inputs for the query.
const newSearchParams = {
...searchParams,
bounds: newBounds,
};
utils.listing.getCoordinates.setData(newSearchParams, () => {
return geoListings.data;
});
navigate({
search: newSearchParams,
});
const newSearchParams = {
...searchParams,
bounds: newBounds,
};
utils.listing.getCoordinates.setData(newSearchParams, () => {
return geoListings.data;
});
navigate({
search: newSearchParams,
});
Its working but I thought maybe there is a better way?
2 replies
DTDrizzle Team
Created by CasperLeerink on 8/19/2023 in #help
Preferred way of adding generated column and unique partial index in schema
I want to add something like this sql in my schema:
ALTER TABLE TaskUsers
ADD COLUMN is_assignee BOOLEAN GENERATED ALWAYS AS (role = 'assignee') STORED;

CREATE UNIQUE INDEX idx_unique_assignee
ON TaskUsers (taskId, is_assignee)
WHERE is_assignee;
ALTER TABLE TaskUsers
ADD COLUMN is_assignee BOOLEAN GENERATED ALWAYS AS (role = 'assignee') STORED;

CREATE UNIQUE INDEX idx_unique_assignee
ON TaskUsers (taskId, is_assignee)
WHERE is_assignee;
what is the preferred way of doing this in drizzle?
3 replies