Tomathy
Tomathy
Explore posts from servers
PPrisma
Created by Tomathy on 11/6/2024 in #help-and-questions
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?
1 replies
PPrisma
Created by Tomathy on 10/23/2024 in #help-and-questions
SSL connection to supabase
Hello, I'm developing an application where the stack includes Prisma as an ORM and the database is hosted by supabase. The app is still in development, and I'm unsure how to make the connection between the development environment and the database be SSL encrypted. That, and how to enforce it also on a production environment. As a disclaimer, I'm using: Prisma + Sveltekit + Supabase. I've also tried to put sslmode=require on the database string, but it fails to establish a connection
18 replies