I have this component
import {
Resource,
component$,
useResource$,
useSignal,
} from "@builder.io/qwik";
import { server$ } from "@builder.io/qwik-city";
import { PrismaClient } from "@prisma/client";
import type { Actions as Action } from "@prisma/client";
import { Loading } from "../loading/loading";
const getActions = server$(async () => {
const prisma = new PrismaClient();
return prisma.actions.findMany();
});
export const Actions = component$(() => {
const loading = useSignal(false);
const actionsResource = useResource$<Action[]>(async () => {
const actions = await getActions();
return actions;
});
return (
<div>
<h1>Actions</h1>
<Resource
value={actionsResource}
onPending={() => <Loading />}
onResolved={(actions) => (
<>
{actions.map((action, index) => (
<pre key={index}>{JSON.stringify(action.data)}</pre>
))}
</>
)}
/>
<button
onClick$={async () => {
loading.value = true;
await server$(async () => {
const prisma = new PrismaClient();
await prisma.actions.deleteMany();
})();
loading.value = false;
}}
>
Clear
</button>
</div>
);
});
When I hit clear, I want to after delete refetch the resource. how should I do this? am I using the wrong pattern?