Stanislav Pugach
10/17/2022, 10:26 PMmodel Tenant {
id Int @id @default(autoincrement())
name String
widgets Widget[]
}
model Widget {
tenant Tenant @relation(fields: [tenantId], references: [id])
tenantId Int
id Int @default(autoincrement())
@@id([tenantId, id])
//...
}
The syntax seems to require the widgets Widget[]
field in the Tenant
model, and the question is: what would happen if the number of total records in the Widget
table is large? Is the array a proactively loaded construct, i.e. would it load the entirety of the DB at all times? Or is the array just syntactic sugar over something that is smarter than that?
Also, is there a way to not require that array field? The schema is likely to be rather large, and the Tenant
model is going to be just lines and lines of those array fields...
Disclaimer: I know there are multitenancy plugins, I'm just comparing the alternatives.Dave Edelhart
10/17/2022, 11:02 PMconst user = await prisma.user.findFirst({
where: {
email,
},
include: {
wishlist: {
include: {
product: {
include: {
images: true,
pricing: {
take: 1,
orderBy: {
createdAt: "desc",
},
},
productDiscount: {
where: {
isValid: true,
},
},
},
},
},
},
Stanislav Pugach
10/17/2022, 11:36 PMDave Edelhart
10/17/2022, 11:38 PMDave Edelhart
10/17/2022, 11:39 PMDave Edelhart
10/17/2022, 11:40 PMStanislav Pugach
10/17/2022, 11:41 PM