Hi friends i have 4 tables, `person` `game` `game...
# orm-help
k
Hi friends i have 4 tables,
person
game
games_played
and
images
The query below finds all the games a person has played and within the
game
table their is a
cover_id
which is a FK to the
images
table. When i generate the prisma sdk, you can see that this relationship between
game
and
images
is identified with the following name
image_game_cover_idToimage
Copy code
image_game_cover_idToimage  image?                    @relation("game_cover_idToimage", fields: [cover_id], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "fk_c529e54ccb5e986f6e8bc52f169b42fe")
can someone explain to me how this naming convention is chosen here and if its possible to give this a different name.
Copy code
const result = await db.games_played.findMany({
  where: { entity_id: person.id },
  distinct: ["game_id"],
  include: { game: { include: { image_game_cover_idToimage: true } } },
});
I guess the kind of solution im looking for is something like;
Copy code
from: { include: { image_game_cover_idToimage: true } }

to: { include: { image_game_cover_idToimage: { as: "image" } } }
k
This is the kind of naming that I believe would happen in the Prisma schema. The following article covers how you might map the relation to a new name. This article also notes that Prisma recommends
PascalCase
instead of
snake_case
https://www.prisma.io/docs/concepts/components/prisma-schema/names-in-underlying-database
k
Yes i saw this but when you generate your entire schema from your db, this does not seem like a feasible option
Considering you have in sql the ability to rename fields and relations using "as" i was hoping i could do this at this level
Just to be clear i only care about the output and then you might say why don't just rename it in javascript once you receive the result. Well thats the option im going down if there is not a nice way to do it