P
Prisma3mo ago
Panic

Kinde + Prisma ORM

Hey all having an issue when implementing Kinde on a personal project. Object literal may only specify known properties, and 'kindeId' does not exist in type 'UserWhereUniqueInput'.ts(2353) import {PrismaClient} from "@prisma/client"; import {getKindeServerSession} from "@kinde-oss/kinde-auth-nextjs/server"; import {NextResponse} from "next/server"; const prisma = new PrismaClient(); export async function GET() { const {getUser} = getKindeServerSession(); const user = await getUser(); if (!user user == null !user.id) throw new Error("something went wrong with authentication" + user); let dbUser = await prisma.user.findUnique({ where: {kindeId: user.id} }); if (!dbUser) { dbUser = await prisma.user.create({ data: { kindeId: user.id, firstName: user.given_name ?? "", lastName: user.family_name ?? "", email: user.email ?? "" // Using nullish coalescing operator to provide a default empty string value } }); } return NextResponse.redirect("http://localhost:3000/dashboard"); } I confirmed that the KindeId is unique in my prisma model. Would love a second pair of eyes.
3 Replies
RaphaelEtim
RaphaelEtim3mo ago
Hi @Panic Did you run npx prisma generate after creating your schema? Can you also share the relevant part of the schema file?
Panic
PanicOP3mo ago
I did
Panic
PanicOP3mo ago
It looks like whatever the first item is in data when I try to create the user is getting the error, so not just the ID. here is the schema.prisma from the generated file // This is your Prisma schema file, // learn more about it in the docs: https://pris.ly/d/prisma-schema // Looking for ways to speed up your queries, or scale easily with your serverless or edge functions? // Try Prisma Accelerate: https://pris.ly/cli/accelerate-init generator client { provider = "prisma-client-js" output = "./generated/client" } datasource db { provider = "mongodb" url = env("DATABASE_URL") } model User { id String @id @default(auto()) @map("_id") @db.ObjectId email String? @unique firstName String? lastName String? kindeId String? @unique posts Post[] createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } model Post { id String @id @default(auto()) @map("_id") @db.ObjectId title String published Boolean @default(false) author User @relation(fields: [authorID], references: [id]) authorID String @map("author_id") @db.ObjectId name String age String email String phone String sleepHours String studyHours String activeDays String stress String sport String wearable String screenTime String fitnessGoals String academicGoals String updatedAt DateTime @updatedAt createdAt DateTime @default(now()) }
Prisma Schema Overview | Prisma Documentation
The Prisma schema is the main method of configuration when using Prisma. It is typically called schema.prisma and contains your database connection and data model.
Prisma
Prisma Accelerate | Make your database queries faster
Accelerate is a managed connection pooler with global caching that helps you speed up your queries with just a few lines of code.
Want results from more Discord servers?
Add your server