Refetching?

Hello I just put up an app using Next 13 app directory and I decided to give Drizzle a try. Everything went great but my data (fetched in a RSC and passed into a client component) is stale. I added new rows to the db, but Drizzle does not refetch. I searched docs and couldn't find an answer. What's the best way to go about refetching periodically?
7 Replies
suck
suck2y ago
i have a feeling it's not a drizzle issue
Thig
ThigOP2y ago
I'm doing it like it says in drizzle ORM
import { db } from "@/db"
import { files } from "@/db/schema"
import { FileList } from "@/components/file-list"

export default async function IndexPage() {
const allFiles = await db.select().from(files)

return (
<section className="container grid items-center gap-6 pb-8 pt-6 md:py-10">
<div className="flex max-w-[980px] flex-col items-start gap-2">
<h1 className="text-3xl font-extrabold leading-tight tracking-tighter md:text-4xl">
This page allows for the downloading of files{" "}
<br className="hidden sm:inline" />
for Snoc.
</h1>
<p className="max-w-[700px] text-lg text-muted-foreground">
Press button, download stuff.
</p>
<p className="max-w-[700px] text-lg text-muted-foreground"></p>
</div>
<FileList allFiles={allFiles} />
</section>
)
}
import { db } from "@/db"
import { files } from "@/db/schema"
import { FileList } from "@/components/file-list"

export default async function IndexPage() {
const allFiles = await db.select().from(files)

return (
<section className="container grid items-center gap-6 pb-8 pt-6 md:py-10">
<div className="flex max-w-[980px] flex-col items-start gap-2">
<h1 className="text-3xl font-extrabold leading-tight tracking-tighter md:text-4xl">
This page allows for the downloading of files{" "}
<br className="hidden sm:inline" />
for Snoc.
</h1>
<p className="max-w-[700px] text-lg text-muted-foreground">
Press button, download stuff.
</p>
<p className="max-w-[700px] text-lg text-muted-foreground"></p>
</div>
<FileList allFiles={allFiles} />
</section>
)
}
This is how I'm seeing everyone else use it: https://github.com/vercel/examples/blob/688af297729c2d817eb30151804fab0565fefe72/storage/postgres-kysely/components/table.tsx#L4 for example
Maston
Maston2y ago
has nothing to do with drizzle, you need to configure your route using route segment configs: https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config for example, if you want to always run a query per request and never cache the page you would add export const revalidate = 0; which ensures the page is always dynamically rendered
File Conventions: Route Segment Config
Learn about how to configure options for Next.js route segments.
Thig
ThigOP2y ago
Thank you Maston, I hadn't known about this. It seems I have a lot more reading to do.
canto
canto9mo ago
.ts
Jitendra
Jitendra9mo ago
I faced this similar problem too. I though it's drizzle but it was next.js export const revalidate = 0; export const dynamic = "force-dynamic";
Want results from more Discord servers?
Add your server