This is the error I have.
I’m trying to update the name in db using prisma. I created the action function to perform the update and it says that nome must not be null. But actually is not null, isn’t it?
Error:
Invalid `prisma.user.update()` invocation:
{
where: {
id: "kp_fa1706a59b5348b384c9e62cb0bf59df"
},
data: {
+ nome: String
}
}
Argument `nome` must not be null.
this is the action:
"use server";
import { getKindeServerSession } from "@kinde-oss/kinde-auth-nextjs/server";
import { redirect } from "next/navigation";
import { prisma } from "./lib/db";
import { Prisma } from "@prisma/client";
export async function updateName() {
const { getUser } = getKindeServerSession();
const user = await getUser();
const formData = new FormData();
if (!user) {
return redirect("/api/auth/login");
}
const nome = formData.get("nome");
try {
await prisma.user.update({
where: {
id: user.id,
},
data: {
nome: nome,
},
});
return {
message: "Succesfully Updated name",
status: "green",
};
} catch (e) {
if (e instanceof Prisma.PrismaClientKnownRequestError) {
if (e.code === "P2002") {
return {
message: "This username is alredy used",
status: "error",
};
}
}
throw e;
}
}
this is my prisma schema
model User {
id String @id
nome String
cognome String
email String
imageUrl String?
Paziente Paziente[]
}
How can I solve the null value for nome (name in english)? Thanks for helping me
New contributor
Federico Fan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.