Unknown argument...Available options are marked with ?.

Hello, I'm facing a problem while seeding my database. I have an implicit many-to-many relation table, and when creating one of the tables, I want to connect some existing rows from the other table into that one, like this:
const invoices: Prisma.InvoiceUncheckedCreateInput[] = [];
const list_aimis: {id: number}[] = faker.helpers.multiple(() => {
return { id: faker.number.int({min: 1, max: 500})}
}, {count: faker.number.int({min: 0, max: 3})}
)
if(list_aimis.length === 0){
invoices.push({
total_value: faker.number.bigInt({min: 10000, max: 1000000}),
invoice_date: faker.date.between({ from: '2020-01-01', to: '2024-12-31' }),
...
clientId: i + 1
})
} else {
invoices.push({
total_value: faker.number.bigInt({min: 10000, max: 1000000}),
invoice_date: faker.date.between({ from: '2020-01-01', to: '2024-12-31' }),
aimi: {
connect: list_aimis,
},
...
clientId: i + 1
})
}
const invoices: Prisma.InvoiceUncheckedCreateInput[] = [];
const list_aimis: {id: number}[] = faker.helpers.multiple(() => {
return { id: faker.number.int({min: 1, max: 500})}
}, {count: faker.number.int({min: 0, max: 3})}
)
if(list_aimis.length === 0){
invoices.push({
total_value: faker.number.bigInt({min: 10000, max: 1000000}),
invoice_date: faker.date.between({ from: '2020-01-01', to: '2024-12-31' }),
...
clientId: i + 1
})
} else {
invoices.push({
total_value: faker.number.bigInt({min: 10000, max: 1000000}),
invoice_date: faker.date.between({ from: '2020-01-01', to: '2024-12-31' }),
aimi: {
connect: list_aimis,
},
...
clientId: i + 1
})
}
The model for invoice:
model Invoice{
id Int @id @default(autoincrement())
client Client @relation(fields: [clientId], references: [id])
clientId Int
total_value BigInt
invoice_date DateTime
obs String?
aimi Aimi[]
...
}
model Invoice{
id Int @id @default(autoincrement())
client Client @relation(fields: [clientId], references: [id])
clientId Int
total_value BigInt
invoice_date DateTime
obs String?
aimi Aimi[]
...
}
I thought that maybe the reason for it was that connect didn't accept empty arrays, so I separated with the if clause. But i keep getting the error:
Unknown argument `aimi`. Did you mean `id`? Available options are marked with ?.
Unknown argument `aimi`. Did you mean `id`? Available options are marked with ?.
It also prints out the invoices array. Can anyone help me?
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server