PrismaP
Prisma2y ago
6 replies
Arthur

Upsert by Reference ID

Hello, I'm trying to upsert data by reference ID but Prisma reject this action

Execution Code

this.prismaService.securityCheque.upsert({
    where: {
        loan_id: payload.loanId,
    },
    create: {
        ...
    },
    update: {
        ...
    },
});


Error

Type '{ loan_id: number; }' is not assignable to type 'SecurityChequeWhereUniqueInput'.


Schema

model Loan {
    id                        Int       @id @default(autoincrement())
    ...
    created_at                DateTime  @default(now())
    updated_at                DateTime  @default(now()) @updatedAt

    // Relations
    security_cheques       SecurityCheque[]

    @@map("loans")
}

model SecurityCheque {
    id             Int      @id @default(autoincrement())
    ...
    created_at     DateTime @default(now())
    updated_at     DateTime @default(now()) @updatedAt

    // Relations
    loan Loan @relation(fields: [loan_id], references: [id])

    @@map("security_cheques")
}
Was this page helpful?