matepapp
07/30/2020, 12:48 PMMarc
07/31/2020, 8:12 AMMayke Freitas
08/06/2020, 1:22 PMdavebeauchemin
08/07/2020, 6:39 PMmodel Cateogory {
id String @id @default(cuid())
name String @unique
}
model SubCategory {
id String @id @default(cuid())
name
parentId Category @relation(fields: [categoryId], references: [id])
categoryId String
}
But I don't know if it's the best approach. The second solution is to get all the category and subCategory in the same type (table) and link the subCategory with the parentId field and if the parentId is null it means it's a top-level category (not a subCategory).
model Category {
id String @id @default(cuid())
name String
parentId String
}
In terms of performance, when I'm on the frontend I need to query all top-level category, select one then show only the children (subCategory) and select another one. Which on is the recommended way to do it? Thanks everyone!Lee Robinson
08/09/2020, 11:48 PMSmakosh
08/12/2020, 6:16 PMChristiano
08/15/2020, 8:52 PMPrismaClient()
in every file (e.g. in my controllers). Did not find any hints in the documentation…
Or does it not matter as long as I call
.finally(async () => {
await prisma.$disconnect()
})
in all my controller
/ route
/ whatever functions?
TyKervin Vasquez
08/17/2020, 6:08 PMLars Ivar Igesund
08/18/2020, 7:19 AMLars Ivar Igesund
08/18/2020, 9:19 AMGreg Egan
08/19/2020, 12:01 AMnikolasburk
Hyo
08/28/2020, 12:37 PMMatthew Caseres
09/01/2020, 12:51 PMMatthew Caseres
09/01/2020, 12:51 PMMatthew Caseres
09/01/2020, 12:52 PMkitze
09/03/2020, 11:20 AMAlbert Gao
09/04/2020, 5:34 AMid
that you gonna attach everywhere, companyId
or tenantId
? 😄Matthew Caseres
09/04/2020, 6:24 AMMatthew Caseres
09/05/2020, 4:12 AMMatthew Caseres
09/05/2020, 4:14 AMMatthew Caseres
09/05/2020, 4:59 AMMatthew Caseres
09/05/2020, 5:00 AMMatthew Caseres
09/05/2020, 6:11 AMMatthew Caseres
09/05/2020, 9:42 AMMatthew Caseres
09/05/2020, 11:50 AM