Next.js Discord

Discord Forum

Prisma use error

Unanswered
Checkered Giant posted this in #help-forum
Open in Discord
Avatar
Checkered GiantOP
"use server"
import { PrismaClient } from '@prisma/client';

const prisma = new PrismaClient();

export async function getOwnedServers(userId: string) {
    return prisma.server.findMany({
        where: {
            userId,
        },
    }) || false
}

export async function getServerById(serverId: string) {
    return prisma.server.findFirst({
        where: {
            id: serverId,
        },
    }) || false
}

this is my servers lib, i get this error
 ⨯ lib\servers.ts (7:26) @ findMany
 ⨯ TypeError: Cannot read properties of undefined (reading 'findMany')
    at getOwnedServers (./lib/servers.ts:17:26)
digest: "128346165"
   5 |
   6 | export async function getOwnedServers(userId: string) {
>  7 |     return prisma.server.findMany({
     |                          ^
   8 |         where: {
   9 |             userId,
  10 |         },
 POST /dashboard/servers 500 in 37ms

and within my visual studio it shows as Property 'server' does not exist on type 'PrismaClient<PrismaClientOptions, never, DefaultArgs>'.ts(2339)

if anyone can help it would be appreciated!

0 Replies