P
Prisma3mo ago
Florian

How do you organize your Prisma.validator schemas?

I have a bunch of predefined select and include schemas. Where do I put them in my project? I need some inspiration.
export function getUserDataSelect(loggedInUserId: string) {
return Prisma.validator<Prisma.UserSelect>()({
...getFollowerInfoSelect(loggedInUserId),
id: true,
username: true,
displayName: true,
avatarUrl: true,
bio: true,
createdAt: true,
_count: {
select: {
posts: true,
followers: true,
},
},
});
}

export type UserData = Prisma.UserGetPayload<{
select: ReturnType<typeof getUserDataSelect>;
}>;
export function getUserDataSelect(loggedInUserId: string) {
return Prisma.validator<Prisma.UserSelect>()({
...getFollowerInfoSelect(loggedInUserId),
id: true,
username: true,
displayName: true,
avatarUrl: true,
bio: true,
createdAt: true,
_count: {
select: {
posts: true,
followers: true,
},
},
});
}

export type UserData = Prisma.UserGetPayload<{
select: ReturnType<typeof getUserDataSelect>;
}>;
1 Reply
Florian
Florian3mo ago
Right now I have them in lib/types.ts together with other types and interfaces. But I don't know if that's the right place.
Want results from more Discord servers?
Add your server