Nichita Z
07/21/2021, 11:28 AMmodel Hashtag {
tag String @id
posts Post[]
}
And i’m trying to count the relations like so:
include: { _count: { select: { posts: true } } },
And it’s throwing the below error.. looks like prisma isn’t generating something correctly? Running prisma migrate dev tells me there’s nothing to generate 😞Tomáš Kallup
07/21/2021, 11:30 AMprisma generate
?Nichita Z
07/21/2021, 11:31 AMNichita Z
07/21/2021, 11:31 AMTomáš Kallup
07/21/2021, 11:32 AMPost
model, could you post that?
Also if your DB has no data, I believe you can use prismage migrate reset
to reset the databse.Nichita Z
07/21/2021, 11:35 AMmodel Post {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
content String
author User @relation(fields: [authorId], references: [id], onDelete: Cascade, onUpdate: Cascade)
authorId Int
tags Hashtag[]
}
Sure, here it is, but it’s way too basic to have any mistakes imo, i think it’s just the migration tool not generating some required fields in the dbTomáš Kallup
07/21/2021, 11:39 AMNichita Z
07/21/2021, 11:41 AMNichita Z
07/21/2021, 12:00 PMmodel Hashtag {
tag String @id
connections HashtagConnection[]
}
// Bypass weird prisma bug
model HashtagConnection {
tagId String
postId Int
tag Hashtag @relation(fields: [tagId], references: [tag])
post Post @relation(fields: [postId], references: [id])
@@id([tagId, postId])
}
Weird as hell, but it works now, though the syntax in prisma client got much uglierRyan
07/22/2021, 5:55 AM