Error Next.JS Prisma client not picking up new models
I created a database table in my schema file as shown below
model Users {
address String @id @unique
paid Boolean @default(false)
}
model Vote {
token String @id @unique
count Int @default(1)
}
and a prisma.ts file with the content below
// lib/prisma.ts
import { PrismaClient } from '@prisma/client';
let prisma: PrismaClient;
if (process.env.NODE_ENV === 'production') {
prisma = new PrismaClient();
} else {
if (!global.prisma) {
global.prisma = new PrismaClient();
}
prisma = global.prisma;
}
export default prisma;
Everything was working fine and I could access my models using the exported prisma variable then I added a new model as shown below
model LaunchPad {
id Int @id @unique @default(autoincrement())
name String
symbol String
tokenId String
total_supply String
decimal String
}
The global prisma variable is not picking up the new model and when I try to use it to save into the database using prisma.launchPad.create() it outputs the error below
TypeError: Cannot read property 'create' of undefined
Admin
2023-04-14
This problems happens sometimes and it has a very simple fix. All you need to do is to close your text editor and open it again
Similar Content
- Setting up dynamic sitemap for next js using Javascript
- Error: `'` can be escaped with `'`, `‘`, `'`
- Error Cannot find module 'react-dom/client' or its corresponding type declarations
- How to Retrieve the Selected Value from a Select Field in ReactJS and NextJS
- Resetting form fields onsubmit in next js
Privacy Policy
By using our website,
you agree that devmaesters can store cookies on your device and disclose information in accordance with our privacy policy.