I have a single instance prisma but it’s not auto-completing any queries.
const { PrismaClient } = require("@prisma/client");
let prisma;
if (process.env.NODE_ENV === "production") {
prisma = new PrismaClient();
prisma.$connect();
} else {
if (!global.__db) {
global.__db = new PrismaClient();
global.__db.$connect();
}
prisma = global.__db;
}
module.exports = prisma;
How can I get autocomplete intellisense 🤷🏻♂️?
4
Answers
Seems like you are using Javascript. The way I was able to get Intellisense autocomplete is by using Typescript and defining the
prisma
variable as follow:let prisma: PrismaClient;
if I remember correctly.I think the Prisma extension for VSCode also includes some Intellisense autocomplete if I am correct.
Worked for me to generate the schemas for the prisma-client
You should have defined in your
schema.prisma
the generator:Then run:
This reads your schema definition and generates a version of
PrismaClient
with all the intellisense related to your models. This command must be executed every time you update your models definition.The process is described here.
I was using VSCode and intellisense for prisma was not working either, even after generating the schema. Restarting VSCode solved it for me. Just reopening the script might solve it too.
./prisma/prisma-client-js.js
index.js
This worked for me