Добрый день.
Делаю сидер, выдает ошибку, кто знает, как решить и в чём причина?
Unknown arg `slug` in data.category.create.slug for type CategoryCreateWithoutProductsInput. Did you mean `select`? Available args:
type CategoryCreateWithoutProductsInput {
title: String
createdAt?: DateTime
updatedAt?: DateTime
}
Вот схемы.
model Product {
id Int @id @default(autoincrement())
title String
slug String @unique
description String
price Int
images String[]
category Category @relation(fields: [categoryId], references: [id])
categoryId Int @map("category_id")
reviews Review[]
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
orderItems OrderItem[]
user User? @relation(fields: [userId], references: [id])
userId Int?
}
model Category {
id Int @id @default(autoincrement())
title String
slug String @unique
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
products Product[]
}
Код.
const product = await prisma.product.create({
data: {
title: productName,
slug: slugify(productName, { locale: 'ru', lower: true }),
description: faker.commerce.productDescription(),
price: +faker.commerce.price(350, 9900, 0),
images: Array.from({
length: faker.datatype.number({ min: 2, max: 7 }),
}).map(() => faker.image.imageUrl()),
category: {
create: {
title: categoryName,
slug: slugify(categoryName, { locale: 'ru', lower: true }),
},
},
reviews: {
create: [
{
rating: faker.datatype.number({ min: 1, max: 5 }),
text: faker.lorem.paragraph(),
user: {
connect: { id: 1 },
},
},
{
rating: faker.datatype.number({ min: 1, max: 5 }),
text: faker.lorem.paragraph(),
user: {
connect: { id: 1 },
},
},
],
},
},
});