P
Prisma8mo ago
Yakuzo

Unknown argument xx. Available options are marked with ?.

Hi everyone, I have an error that I can't solve and I wanted to know if anyone sees an error in my model? I've been stuck on it for a while and I don't really understand why, even though everything seems right. IIt can either be linked to a Track or a Car (not both at the same time), which is why I've added the null option.
model ModsImages {
id String @id @unique
parent_id String
parent_type String
full_name String
name String
type String
metadata Json?
url String
car Cars? @relation("CarImage", fields: [parent_id], references: [signature], map: "mods_images_car_fkey")
track Tracks? @relation("TrackImage", fields: [parent_id], references: [signature], map: "mods_images_track_fkey")

@@map("mods_images")
}

model Cars {
signature String @id @unique
...
images ModsImages[] @relation("CarImage")
...

@@index([variant_of])
@@map("cars")
}
model ModsImages {
id String @id @unique
parent_id String
parent_type String
full_name String
name String
type String
metadata Json?
url String
car Cars? @relation("CarImage", fields: [parent_id], references: [signature], map: "mods_images_car_fkey")
track Tracks? @relation("TrackImage", fields: [parent_id], references: [signature], map: "mods_images_track_fkey")

@@map("mods_images")
}

model Cars {
signature String @id @unique
...
images ModsImages[] @relation("CarImage")
...

@@index([variant_of])
@@map("cars")
}
* I'm creating my Car and all his content with "create" method inside a transaction and create image in it :
const images: Prisma.ModsImagesCreateManyInput[] = car?.images?.map(
(image) => {
const metadata = JSON.parse(JSON.stringify(image.metadata)) ?? null;
console.log("Metadata : ", metadata);
console.log("Image : ", image);

return {
id: image.id,
parent_id: car.signature,
full_name: image.full_name,
name: image.name,
type: image.type,
metadata,
url: image.url,
parent_type: "cars",
};
}
);
...

await transaction.cars.create({
data: {
signature: car.signature,
...
images: {
create: images,
},
s3_folder: {
create: [],
},
},
const images: Prisma.ModsImagesCreateManyInput[] = car?.images?.map(
(image) => {
const metadata = JSON.parse(JSON.stringify(image.metadata)) ?? null;
console.log("Metadata : ", metadata);
console.log("Image : ", image);

return {
id: image.id,
parent_id: car.signature,
full_name: image.full_name,
name: image.name,
type: image.type,
metadata,
url: image.url,
parent_type: "cars",
};
}
);
...

await transaction.cars.create({
data: {
signature: car.signature,
...
images: {
create: images,
},
s3_folder: {
create: [],
},
},
Thanks in advance
1 Reply
Yakuzo
YakuzoOP8mo ago
Well, I just found out that you didn't have to fill in parent_id when creating the image table, it's filled in automatically. But then, I can't put the type
Prisma.ModsImagesCreateManyInput[]
Prisma.ModsImagesCreateManyInput[]
It asks me to fill it in, even though there's a relationship
Want results from more Discord servers?
Add your server