defined relationships not available

21 Views Asked by At

I'm running into a problem when trying to query my database where I have a number of relationships, how ever not all relationships seem to be available when I try to query them. I have the following two models:

model action {
  action_guid                  String                  @id(map: "PK_action_guid") @default(dbgenerated("uuid_generate_v4()")) @db.Uuid
  case_guid                    String                  @db.Uuid
  action_type_action_xref_guid String                  @db.Uuid
  actor_guid                   String                  @db.Uuid
  action_date                  DateTime                @db.Timestamp(6)
  active_ind                   Boolean?
  create_user_id               String                  @db.VarChar(32)
  create_utc_timestamp         DateTime                @db.Timestamp(6)
  update_user_id               String?                 @db.VarChar(32)
  update_utc_timestamp         DateTime?               @db.Timestamp(6)
  equipment_guid               String?                 @db.Uuid
  case_file                    case_file               @relation(fields: [case_guid], references: [case_file_guid], onDelete: NoAction, onUpdate: NoAction, map: "FK_action__case_guid")
  action_type_action_xref      action_type_action_xref @relation(fields: [action_type_action_xref_guid], references: [action_type_action_xref_guid], onDelete: NoAction, onUpdate: NoAction, map: "FK_action_action_type_action_xref")
  equipment                    equipment?              @relation(fields: [equipment_guid], references: [equipment_guid], onDelete: NoAction, onUpdate: NoAction, map: "fk_action__equipment_guid")
}

model action_type_action_xref {
  action_type_action_xref_guid                                                String           @id(map: "PK_action_type_action_xref_guid") @default(dbgenerated("uuid_generate_v4()")) @db.Uuid
  action_type_code                                                            String           @db.VarChar(10)
  action_code                                                                 String           @db.VarChar(10)
  display_order                                                               Int
  active_ind                                                                  Boolean?
  create_user_id                                                              String           @db.VarChar(32)
  create_utc_timestamp                                                        DateTime         @db.Timestamp(6)
  update_user_id                                                              String?          @db.VarChar(32)
  update_utc_timestamp                                                        DateTime?        @db.Timestamp(6)
  action                                                                      action[]
  action_code_action_type_action_xref_action_codeToaction_code                action_code      @relation("action_type_action_xref_action_codeToaction_code", fields: [action_code], references: [action_code], onDelete: NoAction, onUpdate: NoAction, map: "FK_action_type_action_xref__action_code")
  action_type_code_action_type_action_xref_action_type_codeToaction_type_code action_type_code @relation("action_type_action_xref_action_type_codeToaction_type_code", fields: [action_type_code], references: [action_type_code], onDelete: NoAction, onUpdate: NoAction, map: "FK_action_type_action_xref__action_type_code")
}

when I try to join these two models:

const result = await this.prisma.action.findMany({
   include: { 
      action_type_action_xref: true
   }
})

I get the following error: Object literal may only specify known properties, and 'action_type_action_xref' does not exist in type 'actionInclude<DefaultArgs>'.

Now I know the relationship is there and its valid, but I don't know why its causing an error.

0

There are 0 best solutions below