I have some Question for prisma2 join table. and a...
# orm-help
c
I have some Question for prisma2 join table. and also one issue Schema:
Copy code
//other
model LayoutSetting {
  id                     Int                        @id @default(autoincrement())
  relatedLayoutToProduct LayoutSettingLinkProduct[]
}

model LayoutSettingLinkProduct {
  layoutId  Int
  productId Int
  order     Int
  layout    LayoutSetting @relation(fields: [layoutId], references: [id])
  product   Product       @relation(fields: [productId], references: [id])

  @@id([layoutId, productId])
  @@index([order])
}

model Product {
  id                     Int                        @id @default(autoincrement())
  relatedLayoutToProduct LayoutSettingLinkProduct[]
}
After executing many transactions and queries as a batch program, the following errors occurred.
Copy code
Invalid `prisma.layoutSettingLinkProduct.deleteMany()` invocation:


  Failed to validate the query: `Field does not exist on enclosing type.` at `Mutation.deleteManyLayoutSettingLinkProduct`
    at cb (/Users/creejee/*****/renewal-project/*********/node_modules/@*****************/appsync-schema/prisma/generated/client/runtime/index.js:36952:17)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async upsertLayout (/Users/creejee/*****/renewal-project/*********/util/batch/appsync/insertProductData.js:59:9)
    at async task (/Users/creejee/*****/renewal-project/*********/util/batch/appsync/insertProductData.js:496:9) {
  code: 'P2009',
  clientVersion: '3.1.1',
  meta: {
    query_validation_error: 'Field does not exist on enclosing type.',
    query_position: 'Mutation.deleteManyLayoutSettingLinkProduct'
  }
}
The following sample code was written for problem trouble shooting, and there was no error at this time.
Copy code
const layout = await prismaClient.layoutSetting.create({
        data: {},
    });
    const product = await prismaClient.product.create({
        data: {},
    });
    if (layout && product) {
        await prismaClient.layoutSettingLinkProduct.createMany({
            data: {
                layoutId: layout.id,
                productId: product.id,
                order: 1,
            },
        });
        const { count } =
            await prismaClient.layoutSettingLinkProduct.deleteMany({
                where: {
                    layoutId: layout.id,
                },
            });
        console.log(count);
    }
I don’t know what I need to solve the problem, and I don’t know why there’s no error in the sample code... Is this a bug? Or is it my fault?
r
@Cree Jee 👋 It would be great if you could create an issue here with all the transactions and batch queries that you’re performing so that we can look into what’s causing this 🙂
c
@Ryan Okay, I’ll try it… However, if the batch query is large and includes our company’s data, How do I send it?
r
You can send all the private stuff on schemas@prisma.io and mention the issue you create publicly
👍 1
👀 1
c
I Send it data yesterday
👍 2