#Prisma Relations

2 messages · Page 1 of 1 (latest)

real flint
#

I have this Schema for database

model user {
  id                String              @id @default(uuid())
  email             String              @unique
  first_name        String
  last_name         String
  created_at        DateTime            @default(now())
  updated_at        DateTime            @updatedAt
  organization_user organization_user[]

  @@index([email])
}

model organization {
  id                String              @id @default(uuid())
  name              String
  email             String              @unique
  api_key           String              @unique
  address           String
  city              String
  state             String
  zip               String
  country           String
  country_code      String
  created_at        DateTime            @default(now())
  updated_at        DateTime            @updatedAt
  organization_user organization_user[]

  @@unique([email, api_key])
}

enum UserRole {
  MEMBER
  ADMIN
}

model organization_user {
  id              String   @id @default(uuid())
  organization_id String   @map("organization_id")
  user_id         String   @map("user_id")
  role            UserRole @default(MEMBER)
  created_at      DateTime @default(now())
  updated_at      DateTime @updatedAt

  orgainzation organization @relation(fields: [organization_id], references: [id])
  user         user         @relation(fields: [user_id], references: [id])

  @@unique([organization_id, user_id])
  @@index([organization_id])
  @@index([user_id])
}

I want to run this fucntion

const organizations = await this.prismaClient.organizationUser.findMany({
        where: {
          user_id: userId,
        },
        include: {
          organization: true,
        },
      });

but this show me error that
Type '{ organization: true; }' is not assignable to type 'never'.

round oxide
#

This has everything to do with Prisma and nothing to do with Nest, really, so I'm going to redirect you to the Prisma support chat on slack: https://slack.prisma.io/