febreeze
11/23/2021, 9:07 PMLars Ivar Igesund
11/23/2021, 9:10 PMfebreeze
11/23/2021, 9:13 PMfebreeze
11/23/2021, 9:13 PMLars Ivar Igesund
11/23/2021, 9:23 PMfebreeze
11/23/2021, 10:15 PMimport { Comment as CommentSchema } from '@prisma/client';
febreeze
11/23/2021, 10:15 PMfebreeze
11/23/2021, 10:16 PMRyan
11/24/2021, 5:04 AMfebreeze
11/24/2021, 9:36 AMimport {
Comment as CommentSchema,
User as UserSchema
} from '@prisma/client';
type ExtendedCommentSchema = CommentSchema & {
user: UserSchema,
children?: { [key: string]: ExtendedCommentSchema },
_count: {
children: number,
}
}
the schema:
model Comment {
id String @id @default(cuid())
content String
upvotes Int
downvotes Int
userId String
user User? @relation(fields: [userId], references: [id])
votes Vote[]
map Map? @relation(fields: [mapId], references: [id])
mapId String?
parentId String?
Comment Comment? @relation("CommentToComment", fields: [parentId], references: [id])
createdAt DateTime @default(now())
updatedAt DateTime @default(now())
children Comment[] @relation("CommentToComment")
@@map(name: "Comments")
}
febreeze
11/24/2021, 9:38 AMRyan
11/24/2021, 9:49 AMtype T = Prisma.CommentGetPayload<{
select: {
_count: { select: { children: true } }
user: true
children: true
}
}>
febreeze
11/24/2021, 10:44 AMfebreeze
11/24/2021, 2:13 PM