ncls.
ncls.
Explore posts from servers
PPrisma
Created by ncls. on 7/12/2024 in #help-and-questions
How to reference/store a joined primary key?
Will do. Thanks again for the hint. Idk how I missed that all the time...😅
10 replies
PPrisma
Created by ncls. on 7/12/2024 in #help-and-questions
How to reference/store a joined primary key?
Generating a new key doesn't work for my case since the values come from CSV files and should be updated if they already exist (using upsert)
10 replies
PPrisma
Created by ncls. on 7/12/2024 in #help-and-questions
How to reference/store a joined primary key?
I was on this page like 200 times and somehow always managed to miss that...😭 I will try and see if it works tomorrow. Thank you!
10 replies
PPrisma
Created by ncls. on 7/12/2024 in #help-and-questions
How to reference/store a joined primary key?
Bump
10 replies
PPrisma
Created by ncls. on 7/12/2024 in #help-and-questions
How to reference/store a joined primary key?
Bump
10 replies
PPrisma
Created by ncls. on 7/12/2024 in #help-and-questions
How to reference/store a joined primary key?
Bump
10 replies
PPrisma
Created by nikitarevenco on 7/12/2024 in #help-and-questions
Get type of prisma client before it is defined
You can create a type which has all the additional typing and then do
type PrismaClientWithExtension = PrismaClient & {
// All your additional attributes...
}

declare global {
var prisma: PrismaClientWithExtension | undefined;
}
type PrismaClientWithExtension = PrismaClient & {
// All your additional attributes...
}

declare global {
var prisma: PrismaClientWithExtension | undefined;
}
12 replies
PPrisma
Created by nikitarevenco on 7/12/2024 in #help-and-questions
Get type of prisma client before it is defined
Then try my code. I don't know why it would be unsafe to use it.
12 replies
PPrisma
Created by nikitarevenco on 7/12/2024 in #help-and-questions
Get type of prisma client before it is defined
Are you trying to run prisma in the middleware? That doesn't work since the middlware is run on the edge runtime which Prisma can't do
12 replies
PPrisma
Created by nikitarevenco on 7/12/2024 in #help-and-questions
Get type of prisma client before it is defined
I use the following solution in a file called prisma.ts where I then import my client from:
import { PrismaClient } from '@prisma/client';

declare global {
var prisma: PrismaClient | undefined;
}

const prisma = globalThis.prisma || new PrismaClient();

if (process.env.NODE_ENV !== 'production') globalThis.prisma = prisma;

export default prisma;
import { PrismaClient } from '@prisma/client';

declare global {
var prisma: PrismaClient | undefined;
}

const prisma = globalThis.prisma || new PrismaClient();

if (process.env.NODE_ENV !== 'production') globalThis.prisma = prisma;

export default prisma;
12 replies