Kay Khan
11/19/2021, 11:03 AMperson
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
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.
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;
from: { include: { image_game_cover_idToimage: true } }
to: { include: { image_game_cover_idToimage: { as: "image" } } }
Korzun
11/19/2021, 12:24 PMPascalCase
instead of snake_case
https://www.prisma.io/docs/concepts/components/prisma-schema/names-in-underlying-databaseKay Khan
11/19/2021, 12:36 PMKay Khan
11/19/2021, 12:37 PMKay Khan
11/19/2021, 12:44 PM