Happy Monday y’all, hoping to get help creating an...
# prisma-migrate
c
Happy Monday y’all, hoping to get help creating an entry using Post request. The error I am getting is:
Copy code
→ 42   const creatives = await prisma.creative.create({
         data: {
           brandLogo: 'www.test2.png',
           brandName: 'This is a Unique one',
           projectName: 'ProjectName is also unique',
           headerImage: 'www.imageheader.png',
           projectCreative: [
             '<http://anothertest2.com|anothertest2.com>',
             '<http://anothertest3.com|anothertest3.com>',
             '<http://anothertest4.com|anothertest4.com>',
             '<http://anothertest5.com|anothertest5.com>'
           ]
           ~~~~~~~~~~~~~~~~~~~~~
         }
       })

Argument projectCreative: Got invalid value 
[
  '<http://anothertest2.com|anothertest2.com>',
  '<http://anothertest3.com|anothertest3.com>',
  '<http://anothertest4.com|anothertest4.com>',
  '<http://anothertest5.com|anothertest5.com>'
]
on prisma.createOneCreative. Provided List<String>, expected ProjectCreativeCreateNestedManyWithoutCreativeInput:
type ProjectCreativeCreateNestedManyWithoutCreativeInput {
  create?: ProjectCreativeCreateWithoutCreativeInput | List<ProjectCreativeCreateWithoutCreativeInput> | ProjectCreativeUncheckedCreateWithoutCreativeInput | List<ProjectCreativeUncheckedCreateWithoutCreativeInput>
  connectOrCreate?: ProjectCreativeCreateOrConnectWithoutCreativeInput | List<ProjectCreativeCreateOrConnectWithoutCreativeInput>
  createMany?: ProjectCreativeCreateManyCreativeInputEnvelope
  connect?: ProjectCreativeWhereUniqueInput | List<ProjectCreativeWhereUniqueInput>
}
But I defined my models to accept an array of strings:
Copy code
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[]
  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
}
via my POST route:
Copy code
<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:
Copy code
{
  "brandLogo": "www.test2.png",
  "brandName": "This is a Unique one",
  "projectName": "ProjectName is also unique",
  "headerImage": "www.imageheader.png",
  "projectCreative": [
    "<http://anothertest2.com|anothertest2.com>",
    "<http://anothertest3.com|anothertest3.com>",
    "<http://anothertest4.com|anothertest4.com>",
    "<http://anothertest5.com|anothertest5.com>"
  ]
}
Can you help me figure it out?