Issue with trying to get entries where IS NULL
I have defined my schema as
I want to filter loans where repaymentId is null
but this is throwing type error
model Loan {
id String @id @default(uuid())
user User @relation(fields: [userId], references: [id])
userId String
number Int
customer Customer @relation(fields: [customerId], references: [id])
customerId String
ornaments String
grossWeight Decimal
netWeight Decimal
estimatedAmount Int
loanAmount Int
interestRate Decimal
date DateTime
dueDate DateTime
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
repayment Repayment? @relation(fields: [repaymentId], references: [id])
repaymentId String?
@@unique([userId, number])
}
model Repayment {
id String @id @default(uuid())
user User @relation(fields: [userId], references: [id])
userId String
number Int
date DateTime
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
loans Loan[]
@@unique([userId, number])
}model Loan {
id String @id @default(uuid())
user User @relation(fields: [userId], references: [id])
userId String
number Int
customer Customer @relation(fields: [customerId], references: [id])
customerId String
ornaments String
grossWeight Decimal
netWeight Decimal
estimatedAmount Int
loanAmount Int
interestRate Decimal
date DateTime
dueDate DateTime
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
repayment Repayment? @relation(fields: [repaymentId], references: [id])
repaymentId String?
@@unique([userId, number])
}
model Repayment {
id String @id @default(uuid())
user User @relation(fields: [userId], references: [id])
userId String
number Int
date DateTime
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
loans Loan[]
@@unique([userId, number])
}I want to filter loans where repaymentId is null
const outstanding = await prisma.loan.findMany({
where: { user: { email }, repaymentId: null },
});const outstanding = await prisma.loan.findMany({
where: { user: { email }, repaymentId: null },
});but this is throwing type error
Type 'null' is not assignable to type 'string | StringFilter<"Loan"> | undefined'.Type 'null' is not assignable to type 'string | StringFilter<"Loan"> | undefined'.
ORM