KJReactor
12/14/2020, 11:54 AMnikolasburk
model Post {
id Int @default(autoincrement()) @id
title String
author User? @relation(fields: [authorId], references: [id])
authorId Int? @map("author_id")
}
If you're talking about relation fields, then you can name these whatever you like in the first place 🙂
Let me know if that helps or if you have any further questions! 🙌bntzio
12/14/2020, 4:28 PM@@map @KJReactorKJReactor
12/14/2020, 5:52 PMnikolasburk
KJReactor
12/14/2020, 5:53 PMKJReactor
12/14/2020, 6:02 PMuser_id the special name, owner , I wanted to have in a particular type. Then, I mapped the owner field with the apropriate user field with a resolver.KJReactor
12/14/2020, 6:04 PM@map may be doing something similar natively ofcourse. But with @map i would need to do introspection after each change to ensure it works. Am I wrong?KJReactor
12/14/2020, 6:49 PM@map does not work on relation fieldsnikolasburk
I just tested this andÂThat's what I meant with "If you're talking about relation fields, then you can name these whatever you like in the first place". It doesn't make sense to use does not work on relation fields@map
@map on relation fields because these don't exist in the database, so there's nothing to "map" them to 🙂KJReactor
12/14/2020, 7:02 PMuser_id just fine. It wouldn't be an issue to do the same everywhere the user_id FK is needed but I feel providing a better name for the relation field based on model gives more context.