PrismaP
Prisma2y ago
10 replies
Nicklas Smit

Nested queries with mongodb not working.

Hi guys,

I have run into a roadblock in my project where I need to fetch some data via my search operation.

I have the following relations setup:

Product - Variants: 1-many
Variant - InventoryItems: 1-many

in searching InventoryItems I want to query the title of the nested variants - product.

It seems that this kind of nested query is way too complicated for prisma or my indexes/relations are set up incorrectly.

here is an example of a working query...


  const TestRequest = await prisma.inventoryItem.findFirst({
      where: {
        variant: {
          title: "45",
        },
      },
      include: {
        variant: true,
      },
      take: 10,
    })
    console.log("TestRequest", TestRequest)


But if we switch this to a findMany .. we get a timeout!

 This request could not be understood by the server: {"type":"UnknownJsonError","body":{"code":"P6004","message":"The Query did not produce a result within the maximum allowed execution time of 10 seconds."}} (The request id was: 89a58c1a787a929a)


Nesting further into the variants connected product modal we are also met with nothing but a timeout.

for context I have 9769 InventoryItems ,1590 products and 14989 Variants.

I have also attached images.

any help would be much appreciated.
Screenshot_2024-06-27_at_14.49.21.png
Screenshot_2024-06-27_at_14.56.20.png
Screenshot_2024-06-27_at_14.56.32.png
Screenshot_2024-06-27_at_14.56.44.png
Was this page helpful?