#Error on prisma count function
8 messages · Page 1 of 1 (latest)
Hi @arctic ingot
The problem is that it's the only message returned. I have this message and it points to this function.
Besides that I have the file where the function is called.
Can you please provide the complete code for the getNodesCount function and its surrounding context and relevant parts of your prisma/schema.prisma file?
It's the whole function.
I use Tanstack-Query to call getNodesCount like this:
export const useNodesCount = (tenantId: string) => {
const query = useQuery<number, AxiosError>({
queryKey: [QueryKeys.NODES_COUNT, tenantId],
queryFn: () => getNodesCount(tenantId),
});
return query;
};
Then I used it like this in my component:
const { data: nodesCount, isPending: isNodesCountLoading } = useNodesCount(me.tenantId);
{nodesCount > OFFSET && (
<Pagination nodesLength={nodesCount} setPage={setPage} />
)}
And here's my schema for Node:
model Node {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
question Question?
answer Answer?
tags Tag[]
tenant Tenant @relation(fields: [tenantId], references: [id])
tenantId String
@@index([tenantId])
}
Tell me if you need more information
Hi @cerulean flax, Can you use console.log to verify Prisma's availability before the count call? Can you also check that Prisma is imported correctly in the getNodesCount function?
Shouldn't you provide an object, key-value pair into the count function
Like so: {tenantId: tenantId}
@arctic ingot I solved it by moving the function to the backend and fetching this data in the front instead of having everything in the front.
What autocomplete option does Typescript provide when typing?