Welcome to the Kinde community.

P
K
A
A
A

Using Prisma to MongoDB With Kinde

Hello,

I'm getting this error when trying to store a user id to a KindeId in my prisma ORM

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.
C
P
6 comments
Hey @Panic I need to refer this to our team to look into this. But someone in the community here might have an idea while you wait.
You might also use #⚡⏐ask-kinde-ai to see if there's an answer
@Panic I can see you are using Next.js. Can you also tell me your Kinde domain please.
I've resolved the problem by changing to a postgres db however now when I have the app running and I sign in, I get a http error 500. @Claire_Kinde any suggestions? Much appreciated
Are you using the latest version of Next.js?
Add a reply
Sign up and join the conversation on Discord
Join