i want to make new holding. there are two cases.
- there are no product, no account.
- there are one product, account.
so i use connectOrCreate!. I want to find accountNum with userId and accountNumber so i use AND in where. but there are error.
Unknown arg AND in data.accountNum.connectOrCreate.where.AND for type AccountNumberWhereUniqueInput. Did you mean id? Available args
const holding = await client.holding.create({
data: {
holdingNum,
accountNum: {
connectOrCreate: {
where: { AND: [{ userId: loggedInUser.id }, { accountNumber }] },
create: {
accountNumber,
user: {
connect: {
id: loggedInUser.id,
},
},
org: {
connect: {
orgCode,
},
},
},
},
},
product: {
connectOrCreate: {
where: {
prodCode,
},
create: {
prodCode,
prodName,
},
},
},
},
});
model AccountNumber {
id Int @id @default(autoincrement())
org Organization @relation(fields: [orgId], references: [id])
orgId Int
user User @relation(fields: [userId], references: [id])
userId Int
accountNum String
holdings Holding[]
}
model Holding {
id Int @id @default(autoincrement())
accountNum AccountNumber @relation(fields: [accountNumId], references: [id])
accountNumId Int
product Product @relation(fields: [productId], references: [id])
productId Int
holdingNum Int
evalAmt Int?
}
model Product {
id Int @id @default(autoincrement())
prodName String
prodCode String @unique
posts Post[]
holdings Holding[]
proposes Propose[]
}