-
Notifications
You must be signed in to change notification settings - Fork 2k
docs(prisma-recipe): update docs for Prisma client output path and build config #3298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
docs(prisma-recipe): update docs for Prisma client output path and build config #3298
Conversation
hey, do you have the full example. how to configure prisma using custom output path and new prisma-client which supports es-module without rust engine. i am talking about prisma v6.16.0 |
@alifarooq-zk It’s not like you need that many extra steps to configure it, at least according to the documentation. So, I suppose the full code would look something like this:
generator client {
provider = "prisma-client-js"
output = "../generated/prisma"
engineType = "client"
}
model User {
id Int @id @default(autoincrement())
email String @unique
name String?
}
import { PrismaPg } from '@prisma/adapter-pg';
import { PrismaClient } from '@generated/prisma';
import { Injectable, OnModuleInit } from '@nestjs/common';
@Injectable()
export class DatabaseService extends PrismaClient implements OnModuleInit {
constructor() {
const adapter = new PrismaPg({ connectionString: process.env.POSTGRES_DATABASE_URL });
super({ adapter });
}
async onModuleInit() {
await this.$connect();
}
} |
This one generates CommonJS (prisma-client-js), i wanted to use latest esm supported prisma (prisma-client) in NestJS. but it seems like NestJS does not support ESM. |
@alifarooq-zk That is possible, but it will cause some trouble with custom paths if you are using them. Here is an example what you need to do:
{
"type": "module",
}
{
"compilerOptions": {
"module": "NodeNext",
"moduleResolution": "NodeNext",
"resolveJsonModule": true,
"esModuleInterop": true,
},
}
generator client {
provider = "prisma-client"
output = "../generated/prisma"
engineType = "client"
runtime = "nodejs"
moduleFormat = "esm"
generatedFileExtension = "ts"
importFileExtension = "js"
}
import { PrismaPg } from '@prisma/adapter-pg';
import { Injectable, OnModuleInit } from '@nestjs/common';
import { PrismaClient } from '../../generated/prisma/client.js';
@Injectable()
export class DatabaseService extends PrismaClient implements OnModuleInit {
constructor() {
const adapter = new PrismaPg({ connectionString: process.env.POSTGRES_DATABASE_URL });
super({ adapter });
}
async onModuleInit() {
await this.$connect();
}
} |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
There is no documentation explaining how to set a custom Prisma client output path or how to ensure it's included in the NestJS build process.
Issue Number: N/A
What is the new behavior?
Adds documentation explaining:
Does this PR introduce a breaking change?
Other information