Is it possible to rename this join `image_imageTo...
# orm-help
k
Is it possible to rename this join
image_imageToperson_profile_image_id
Copy code
const data: any = await prisma.mview_entity_inheritance.findMany({
        include: {
            person: { include: { image_imageToperson_profile_image_id: true } },
        },
        where: { service_id: { in: serviceIds } },
    });
s
Can you share your schema file?
k
I make use of the introspect feature of prisma, i could directly change that in the schema but defeats the purpose of my usecase of being able to just introspect and forget
Copy code
model person {
  id                                   String                     @id @db.VarChar(36)
  name                                 String?                    @db.VarChar(64)
  slug                                 String?                    @db.VarChar(64)
  synchronization_id                   Int?
  about                                String?                    @db.Text
  profile_image_id                     String?                    @db.VarChar(36)
  banner_id                            String?                    @db.VarChar(36)
  created_at                           DateTime?                  @default(now()) @db.Timestamp(0)
  updated_at                           DateTime?                  @default(now()) @db.Timestamp(0)
  deleted_at                           DateTime?                  @db.Timestamp(0)
  image_imageToperson_banner_id        image?                     @relation("imageToperson_banner_id", fields: [banner_id], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "fk_53fcbe74e2487ccc367f4a04284d54c9")
  image_imageToperson_profile_image_id image?                     @relation("imageToperson_profile_image_id", fields: [profile_image_id], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "fk_04722b345389a0ac105d09c70d4f20e2")
  synchronization                      synchronization?           @relation(fields: [synchronization_id], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "fk_bbd63d7efe7f96034eb80433265059f5")
  channel_person                       channel_person[]
  engagement_score                     engagement_score[]
  entity_aliases                       entity_aliases[]
  games_played                         games_played[]
  list_member                          list_member[]
  list_member_dynamic                  list_member_dynamic[]
  mview_campaign                       mview_campaign[]
  mview_entity_inheritance             mview_entity_inheritance[]
  mview_sponsorship                    mview_sponsorship[]
  mview_team_player                    mview_team_player[]
  news_entity                          news_entity[]
  person_game                          person_game[]
  person_location                      person_location[]
  person_player                        person_player?
  user_person_follow                   user_person_follow[]
  website_link                         website_link[]

  @@index([profile_image_id], map: "fk_04722b345389a0ac105d09c70d4f20e2")
  @@index([banner_id], map: "fk_53fcbe74e2487ccc367f4a04284d54c9")
  @@index([deleted_at], map: "index_deleted")
  @@index([slug], map: "index_slug")
  @@index([synchronization_id], map: "index_sync")
}
if i can't do it directly i could just simply map the result at the end
s
Oh yeah, you should be able to just name that column whatever you'd like in the schema because it is a relation scalar field that doesn't actually correspond to a column in the database (if I understand correctly). Next time you introspect it should maintain your changes
k
really!?
Copy code
Next time you introspect it should maintain your changes
s
Yep!! Pretty awesome, right? 🙂
k
yeah
s
But yeah, so long as that field is a generated field (doesn't actually exist in your database) you're free to name it whatever you want. If it IS a field in your db, you can use the
@map()
attribute to give it a name in your code while maintaining the name in the DB
k
thanks!
s
Sure thing!