Currently, I am utilizing Expressjs as a backend along with Prisma for database management and TypeScript implementation. I have been referencing this specific article in my development process.
A type error that I am encountering is stated as
Property 'job' does not exist on type 'PrismaClient<PrismaClientOptions, never, RejectOnNotFound | RejectPerOperation | undefined>'
Provided below is a snippet of my code:
import { PrismaClient } from '@prisma/client';
import app from './app';
const prisma = new PrismaClient();
app.post('/job', async (req, res) => {
const job = await prisma.job.create({ data: req.body });
res.json(job);
});
app.get('/', async (req, res) => {
const job = await prisma.job.findMany();
res.json(job);
});
The specific error arises here await prisma.job.create()
Furthermore, this is the prisma.schema structure:
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "sqlserver"
url = env("DATABASE_URL")
}
model User {
id Int @id @default(autoincrement())
email String @unique
name String?
posts Post[]
}
model Post {
id Int @id @default(autoincrement())
title String
content String?
published Boolean @default(false)
author User @relation(fields: [authorId], references: [id])
authorId Int
}
model Job {
id Int @id @default(autoincrement())
title String
location String
salary String
}
If possible, could someone assist me with this issue? Any help will be greatly appreciated.