Christian Goebel
11/29/2021, 10:07 PMlet db_results
let all_entries = await getMyEntriesFromExternalAPI();
for (const entry of entries) {
if (await doesEntryExistInDatabase(entry.invoice_id)) {
continue
}
//... do some heavy lifting here
let sub_entries = []
for (let i = 0; i < entry.number_of_sub_entries; i++) {
let sub_entry = {
prop1: "Name",
counter: i
}
sub_entries.push(sub_entry)
}
let db_input = {
prop1: "some Value",
prop2: entry.invoice_id,
sub_entries: {
create: {
sub_entries
}
}
}
let db_result = await db.mytable.create({ data: db_input })
db_results.push(db_result)
}
console.log({ lenght: db_results.lenght })
So I have ~200 entries in "all_entries", if I look at the database, I can see ~350 entries and "db_results.length" counts 170 entries!?
All this performed on a completely empty database. Any ideas?
Many thanks in advance!Fergus Meiklejohn
11/30/2021, 2:54 AMmodel User {
id Int @id @default(autoincrement())
name String
comments Comment[]
}
model Comment {
id Int @id @default(autoincrement())
text String
userId Int
user User @relation(fields: [userId], references: [id])
room RoomComments[]
}
model Room {
id Int @id @default(autoincrement())
name String
comments RoomComments[]
}
model RoomComments {
roomId Int
commentId Int
room Room @relation(fields: [roomId], references: [id])
comment Comment @relation(fields: [commentId], references: [id])
@@id([roomId, commentId])
}
My question is this: Room can can many comments so comments RoomComments[]
makes sense, but a Comment cannot have many Rooms so room RoomComments[]
isn't correct. But if I remove the []
I get an error in the RoomComments model and am required to make comment Comment?
optional, which isn't right either.
I must be missing something, I apologise, but it looks like prisma can't express the relation as I'd like.
Thanks for any help you can give! :-)Bård
11/30/2021, 8:57 AMwarn(prisma-client) Already 10 Prisma Clients are actively running.
When running
npx prisma studio
This only happens when I run the studio, the normal app is not even running and I never get the error if I only run the app.
The studio is connected to the DB with a connection pool with the pgbouncer=true param.
Any ideas why?user
11/30/2021, 10:45 AMMarvin
11/30/2021, 1:25 PMshadowDatabaseUrl
defined in my schema.prisma
which I need for development. In production, the value is empty because I don't provide it and the deployment fails. The Prisma docs say that it's not required in production, but what's the workaround for this? Do I need to provide the env variable in production still, or can I omit it somehow?joao.santos
11/30/2021, 2:16 PMDev__
11/30/2021, 2:30 PMRaif Harik
11/30/2021, 2:39 PMChris Bitoy
11/30/2021, 2:43 PMRaif Harik
11/30/2021, 2:43 PMRaif Harik
11/30/2021, 2:44 PMjoao.santos
11/30/2021, 2:48 PMuser
11/30/2021, 3:18 PMJohn McElreavey
11/30/2021, 3:37 PMChris Bitoy
11/30/2021, 3:47 PMPaul
11/30/2021, 3:57 PMPaul
11/30/2021, 3:58 PMTom MacWright
11/30/2021, 4:13 PMGarrett Tolbert
11/30/2021, 4:23 PMDaniell
11/30/2021, 4:32 PMid String @id @db.VarChar(19)
but maybe there is something more accurateJames Homer
11/30/2021, 5:30 PMJames Homer
11/30/2021, 5:31 PMJames Homer
11/30/2021, 5:33 PMCliff
11/30/2021, 5:40 PMJames Homer
11/30/2021, 5:43 PMMaguire Krist
11/30/2021, 6:04 PMMaguire Krist
11/30/2021, 6:04 PMMaguire Krist
11/30/2021, 6:05 PMWahyu
11/30/2021, 6:29 PMDaniel De La Luz
11/30/2021, 8:15 PM