Hey, I'm getting a weird error and I just can't fi...
# orm-help
i
Hey, I'm getting a weird error and I just can't figure out why. “TypeError: Cannot read properties of undefined (reading 'accounts')” Can I get some help?
m
Not without seeing some code
i
I'll grab some now
Code:
Copy code
js
import express from 'express'
const app = express()
const PORT = 80;
import pkg from '@prisma/client'
const { PrismaClient } = pkg
const prisma = new PrismaClient()

app.use(express.json())

app.get("/user/get", function (req, res) {
    var key = req.header("API")
    if (prisma.$exists.accounts({apiKey: key})) {
        prisma.user.user.findmany({where: {token: req.body}})
    }
    else {res.status(400)}
    res.status(400).send("Cheese")
})



app.listen(PORT, () => console.log(`Serving on 0.0.0.0:${PORT}`))
m
@ItsMeAlfie0 What is $exists? It seems you're trying an old code from Prisma 1 in Prisma 2
You have also
user
twice and it should be
findMany
:
prisma.user.user.findmany({where: {token: req.body}})
But $exists doesn't exist 😈
👍 1