have a model with stores and articles. stores have many articles and articles many stores
As this is an implicit M2N, Prisma has generated automatically the Join table _articlesTohypermarches_stores
The max number of articles per store is 10K, but I want for example only the 10 first and not the whole 10K
I tried to apply pagination when querying the stores but the query sent to the _articlesTohypermarches_stores table has no LIMIT 10 thus resulting in fetching the 10K articles...
here are the query I'm testing, the model and the the queries sent to POSTGRES by Prisma, as well as the PRISMA Logs that showing the pb.
const test = await prisma.hypermarches_stores.findMany({
where: {
id: {
equals: 209,
},
},
select: {
stoDisplayDesc: true,
articles: {
take: 10, // <--- this is not taking into account
skip: 1,
select: {
title: true,
},
},
},
take: 2,
});
model articles {
id Int @id(map: "PK_0a6e2c450d83e0b6052c2793334") @default(autoincrement())
title String? @default("") @db.VarChar(3000)
prioriteId Int?
isAlerte Boolean? @default(false)
categorieId Int?
publicationStartDate DateTime? @default(dbgenerated("'2021-12-29 17:02:14.651'::timestamp without time zone")) @db.Timestamp(6)
publicationEndDate DateTime? @default(dbgenerated("'2021-12-29 17:02:14.651'::timestamp without time zone")) @db.Timestamp(6)
hasAction Boolean? @default(false)
briefDescription String? @default("") @db.VarChar(3000)
content String? @default("")
contact1 String? @default("") @db.VarChar(300)
contact2 String? @default("") @db.VarChar(300)
author String? @default("") @db.VarChar(300)
recordCreationDate DateTime @default(now()) @db.Timestamp(6)
recordUpdateDate DateTime @default(now()) @db.Timestamp(6)
ref_categories ref_categories? @relation(fields: [categorieId], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "FK_278d87b271a80d56e5d6cc0f888")
ref_priorites ref_priorites? @relation(fields: [prioriteId], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "FK_a55acd217d26e0d60f57b5f38f7")
articles_documents articles_documents[]
fonctions ref_fonctions[]
magasins hypermarches_stores[]
metiers ref_metiers[]
perimetres ref_perimetres[]
poles ref_poles[]
services ref_services[]
articles_statuts_contribution articles_statuts_contribution[]
@@index([id], map: "IDX_0a6e2c450d83e0b6052c279333")
}
model hypermarches_stores {
id Int @id(map: "PK_7b1178bff8dc98cbd6d68fc2dd0") @default(autoincrement())
stoEan String @unique(map: "UQ_7fddfa16362979011e27b4d0b21") @db.VarChar(300)
articles articles[]
@@index([id], map: "IDX_7b1178bff8dc98cbd6d68fc2dd")
}
