Chris Bitoy
12/06/2021, 8:00 PMconst creatives = await prisma.creative.create({
data: {
brandLogo: 'www.test3.png',
brandName: 'This another one',
projectName: 'ProjectName is unique',
headerImage: 'www.imageheader4.png',
projectCreative: {
cloudinary_url0: '<http://anothertest32.com|anothertest32.com>',
~~~~~~~~~~~~~~~
cloudinary_url1: '<http://anothertest33.com|anothertest33.com>',
~~~~~~~~~~~~~~~
cloudinary_url2: '<http://anothertest44.com|anothertest44.com>',
~~~~~~~~~~~~~~~
cloudinary_url3: '<http://anothertest59.com|anothertest59.com>'
~~~~~~~~~~~~~~~
}
}
})
Unknown arg `cloudinary_url0` in data.projectCreative.cloudinary_url0 for type ProjectCreativeCreateNestedManyWithoutCreativeInput. Did you mean `createMany`? Available args:
type ProjectCreativeCreateNestedManyWithoutCreativeInput {
create?: ProjectCreativeCreateWithoutCreativeInput | List<ProjectCreativeCreateWithoutCreativeInput> | ProjectCreativeUncheckedCreateWithoutCreativeInput | List<ProjectCreativeUncheckedCreateWithoutCreativeInput>
connectOrCreate?: ProjectCreativeCreateOrConnectWithoutCreativeInput | List<ProjectCreativeCreateOrConnectWithoutCreativeInput>
createMany?: ProjectCreativeCreateManyCreativeInputEnvelope
connect?: ProjectCreativeWhereUniqueInput | List<ProjectCreativeWhereUniqueInput>
}
Unknown arg `cloudinary_url1` in data.projectCreative.cloudinary_url1 for type ProjectCreativeCreateNestedManyWithoutCreativeInput. Did you mean `createMany`? Available args:
type ProjectCreativeCreateNestedManyWithoutCreativeInput {
create?: ProjectCreativeCreateWithoutCreativeInput | List<ProjectCreativeCreateWithoutCreativeInput> | ProjectCreativeUncheckedCreateWithoutCreativeInput | List<ProjectCreativeUncheckedCreateWithoutCreativeInput>
connectOrCreate?: ProjectCreativeCreateOrConnectWithoutCreativeInput | List<ProjectCreativeCreateOrConnectWithoutCreativeInput>
createMany?: ProjectCreativeCreateManyCreativeInputEnvelope
connect?: ProjectCreativeWhereUniqueInput | List<ProjectCreativeWhereUniqueInput>
}
Unknown arg `cloudinary_url2` in data.projectCreative.cloudinary_url2 for type ProjectCreativeCreateNestedManyWithoutCreativeInput. Did you mean `createMany`? Available args:
type ProjectCreativeCreateNestedManyWithoutCreativeInput {
create?: ProjectCreativeCreateWithoutCreativeInput | List<ProjectCreativeCreateWithoutCreativeInput> | ProjectCreativeUncheckedCreateWithoutCreativeInput | List<ProjectCreativeUncheckedCreateWithoutCreativeInput>
connectOrCreate?: ProjectCreativeCreateOrConnectWithoutCreativeInput | List<ProjectCreativeCreateOrConnectWithoutCreativeInput>
createMany?: ProjectCreativeCreateManyCreativeInputEnvelope
connect?: ProjectCreativeWhereUniqueInput | List<ProjectCreativeWhereUniqueInput>
}
Unknown arg `cloudinary_url3` in data.projectCreative.cloudinary_url3 for type ProjectCreativeCreateNestedManyWithoutCreativeInput. Did you mean `createMany`? Available args:
type ProjectCreativeCreateNestedManyWithoutCreativeInput {
create?: ProjectCreativeCreateWithoutCreativeInput | List<ProjectCreativeCreateWithoutCreativeInput> | ProjectCreativeUncheckedCreateWithoutCreativeInput | List<ProjectCreativeUncheckedCreateWithoutCreativeInput>
connectOrCreate?: ProjectCreativeCreateOrConnectWithoutCreativeInput | List<ProjectCreativeCreateOrConnectWithoutCreativeInput>
createMany?: ProjectCreativeCreateManyCreativeInputEnvelope
connect?: ProjectCreativeWhereUniqueInput | List<ProjectCreativeWhereUniqueInput>
}
I defined my models to accept an array of strings as show below:
model Creative {
id Int @id @default(autoincrement())
owner_id String @default(cuid())
campaign_id String @default(cuid())
parent_c_id String @default(cuid())
brandLogo String
brandName String @unique
projectName String @unique
headerImage String
projectCreative ProjectCreative[] //should accept array of strings
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model ProjectCreative {
id Int @id @default(autoincrement())
creative Creative? @relation(fields: [creativeId], references: [id])
creativeId Int?
cloudinary_url0 String
cloudinary_url1 String
cloudinary_url2 String
cloudinary_url3 String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
And in my POST route:
<http://router.post|router.post>("/creatives", async (req, res) => {
try {
const { brandLogo, brandName, projectName, headerImage, projectCreative } =
req.body;
const creatives = await prisma.creative.create({
data: { brandLogo, brandName, projectName, headerImage, projectCreative },
});
res.status(201).json({ success: true, data: creatives, error: "" });
} catch (error) {
console.log(error);
res.status(500).json({ data: {}, error: error, status: 500 });
}
});
With this test data:
{
"brandLogo": "www.test2.png",
"brandName": "This is a Unique one",
"projectName": "ProjectName is also unique",
"headerImage": "www.imageheader.png",
"projectCreative": {
"cloudinary_url0": "<http://anothertest32.com|anothertest32.com>",
"cloudinary_url1": "<http://anothertest33.com|anothertest33.com>",
"cloudinary_url2": "<http://anothertest44.com|anothertest44.com>",
"cloudinary_url3": "<http://anothertest59.com|anothertest59.com>"
}
Can you help me figure it out?Maciek K
12/06/2021, 8:10 PMconst creatives = await prisma.creative.create({
data: {
brandLogo: 'www.test3.png',
brandName: 'This another one',
projectName: 'ProjectName is unique',
headerImage: 'www.imageheader4.png',
projectCreative:
create {
cloudinary_url0: '<http://anothertest32.com|anothertest32.com>',
cloudinary_url1: '<http://anothertest33.com|anothertest33.com>',
cloudinary_url2: '<http://anothertest44.com|anothertest44.com>',
cloudinary_url3: '<http://anothertest59.com|anothertest59.com>'
}
}
}
})
Chris Bitoy
12/06/2021, 8:15 PM