Insert an Array into an array field.
RalphLincoln opened this issue · 0 comments
RalphLincoln commented
model Campaign {
id String @id @default(auto()) @map("_id") @db.ObjectId
name String
description String
admin AdminConsumer @relation(fields: [admin_id], references: [id])
admin_id String @db.ObjectId
campaign_identifier String @unique
creative ConsumerCreatives @relation(fields: [creative_id], references: [id])
creative_id String @unique @db.ObjectId
campaign_goals CampaignGoals[] @relation(fields: [campaign_goals_id], references: [id])
campaign_goals_id String[] @db.ObjectId
media Media[] @relation(fields: [media_id], references: [id])
media_id String[] @db.ObjectId
flight_date DateTime?
expiration_date DateTime?
campaign_tracking CampaignTracking[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
type CreateCampaignModel struct {
Name string `json:"name" bson:"name" validate:"required"`
Media []string `json:"media" bson:"media" validate:"required"`
UserID string `json:"user_id" bson:"user_id" validate:"required"`
Creatives string `json:"creatives" bson:"creatives" validate:"required"`
Description string `json:"description" bson:"description" validate:"required"`
CampaignGoals []string `json:"campaign_goals" bson:"campaign_goals" validate:"required"`
}
With the schema model above, how do I insert CreateCampaignModel.Media using client.Campaign.CreateOne