`thread '<unnamed>' panicked at 'Did not find a relation for model users and field editedmessages'`
See original GitHub issuegenerator client { provider = "prisma-client-js" previewFeatures = ["mongoDb", "fullTextSearch"] } datasource db { provider = "mongodb" url = env("DATABASE_URL") } model editedmessages { id String @id @default(auto()) @map("_id") @db.ObjectId userId String oldMessage String newMessage String editDate String messageID String user users @relation("users", fields: [userId], references: [userId], onDelete: NoAction, onUpdate: NoAction) users users[] } model stafftags { id String @id @default(auto()) @map("_id") @db.ObjectId v Int @map("__v") fullMessage String type String[] userId String } model statistics { id String @id @default(auto()) @map("_id") @db.ObjectId v Int @map("__v") date String total Int type String } model users { id String @id @default(auto()) @map("_id") @db.ObjectId v Int @map("__v") avatarURL String firstMessage String lastMessage String? userId String @unique(map: "userId_1") username String @unique(map: "username_1") statistics userstatistics @relation(fields: [userId], references: [userId]) userstatistics userstatistics[] @relation("users") message editedmessages @relation(fields: [userId], references: [userId]) editedmessages editedmessages[] @relation("users") } model userstatistics { id String @id @default(auto()) @map("_id") @db.ObjectId v Int @map("__v") total Int userId String user users @relation("users", fields: [userId], references: [userId], onDelete: NoAction, onUpdate: NoAction) users users[] } model webusers { id String @id @default(auto()) @map("_id") @db.ObjectId username String password String email String admin Boolean }
Throws an error,
❯ npx prisma format Prisma schema loaded from prisma\schema.prisma thread '<unnamed>' panicked at 'Did not find a relation for model users and field editedmessages', query-engine\prisma-models\src\builders\internal_dm_builder.rs:122:25 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace Error: Unexpected token D in JSON at position 0
_Originally posted by @schwarzsky in https://github.com/prisma/prisma/issues/4854#issuecomment-1117845073_
Issue Analytics
- State:
- Created a year ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
This Week in Matrix 2022-12-02
Display names of Slack users should be kept up-to-date more reliably. Support is added for bridging Slack threads with MSC3440 m.thread relations.
Read more >Querying models based on their relations existence
Problem. Common use cases when querying for relations from a database are: finding all the entities for table X where the relation Y...
Read more >Mattermost self-hosted changelog
Fixed an issue where Get categories with the “exclude” option did not return ... Users are unable to open threads from recent mentions...
Read more >Mozilla is giving up on their IRC server
Users reporting spam is done by them sending a message to an admin ... It is paid for by someone, but I don't...
Read more >Unable to solve Prisma 1 - 1 and 1 - n relation error
Issue Resolved Update. After I do prisma migrate save , prisma migrate up and prisma generate , I stopped the server running via...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Here is a more minimal version of the schema that shows the same crash:
The problem that seems to be causing this is that both relations are called
users
- changing 2 connected instances ifusers
tousers2
makes the schema pass validation:Was this schema created via Introspection @schwarzsky? It looks a bit like that. If so, can you open another issue and post a minimal sample of the data to create that schema via Introspection? That both relations get the same name is a bug that needs to be fixed as well.
Thanks. Any help apprecaited.