Typescript one to many relation

I'm trying to create a record like this:
await db.limits.create({
data: {
...limit,
id: undefined,
trimorders: allTrimorders
},
});
await db.limits.create({
data: {
...limit,
id: undefined,
trimorders: allTrimorders
},
});
However, typescript complains about the trimorders field: Type '{ id: number; ticker: string; price: number; dir: string; shares: number; userid: number; }[]' is not assignable to type 'TrimOrdersUncheckedCreateNestedManyWithoutLimitInput | TrimOrdersCreateNestedManyWithoutLimitInput | undefined'. These are the schemas:
model limits {
ticker String
price Float
stoploss Float?
takeprofit Float?
id Int @id @default(autoincrement())
userid Int
amount Int
style String
dir String
type String

trimorders TrimOrders[]
}


model TrimOrders {
id Int @id @default(autoincrement())
ticker String
price Float
dir String
shares Int
userid Int

user users @relation(fields: [userid], references: [id])
limit limits? @relation(fields: [id], references: [id])
}
model limits {
ticker String
price Float
stoploss Float?
takeprofit Float?
id Int @id @default(autoincrement())
userid Int
amount Int
style String
dir String
type String

trimorders TrimOrders[]
}


model TrimOrders {
id Int @id @default(autoincrement())
ticker String
price Float
dir String
shares Int
userid Int

user users @relation(fields: [userid], references: [id])
limit limits? @relation(fields: [id], references: [id])
}
1 Reply
Nurul
Nurul5mo ago
What are you passing in the limit and allTrimorders variable?
Want results from more Discord servers?
Add your server