In my project, I wrote a function using the prisma client
which is being called from the notes.tsx
route in remix.
export async function createNote(entity: { title: string, description: string }) {
const note = await prisma.note.create({
data: {
title: entity.title,
description: entity.description,
userId: mainUser.id,
},
});
console.log(note);
return note;
}
The action defined in the notes.tsx
route which utilizes the createNote
function is as follows:
export async function action(data: any) {
const { request } = data;
const formData = await request.formData();
console.log(formData
, ...formData.entries());
const noteData: Note = {
title: formData.get("title")?.toString() ?? "",
description: formData.get("description")?.toString() ?? "",
};
const note = await createNote(noteData);
console.log(`New note created => Note:`, note);
}
When attempting to execute the code, an error occurs instead of creating a new record in the database,
TypeError: (0 , import_prisma.createNote) is not a function
at action (file:///Users/user/workspaces/ts/remix-workspace/project/app/routes/notes.tsx:27:24)
I have identified the issue. It seems that any functions exported from the prisma client to remix are not functioning properly. Despite correctly defining the function, upon testing with another function in prisma client, I encountered the same error indicating that the new function does not exist. How can this issue be resolved? Thank you.