hey folks, I'm trying something new ... MongoDB i...
# prisma-client
r
hey folks, I'm trying something new ... MongoDB i've managed to convert my schema into a mongo "happy" format, but when I try to write data, I'm getting some errors when I'm linking to documents in other collections
Copy code
//schema

model activityLog {
  activityLogId      String                @id @map("_id") @default(uuid())
  activityLogType    activityLogType       @relation(fields: [activityLogTypeId], references: [activityLogType])
  activityLogTypeId  String                @db.ObjectId()
  activityLogMessage String                @db.String
  activityCompleted  Boolean               @default(false)
  createdAt          DateTime              @default(now()) @db.Timestamp
  updatedAt          DateTime              @default(now()) @db.Timestamp
}

model activityLogType {
  activityLogType     String                @id @map("_id")  @db.String
  createdAt           DateTime              @default(now()) @db.Timestamp
  updatedAt           DateTime              @default(now()) @db.Timestamp
  activityLog         activityLog[]
}
when I try to do
Copy code
await prisma.activityLog.create({
    data: {
      activityLogType: {
        activityLogType: "Start"
      },
      activityLogMessage: "Start Seeding",
      activityCompleted: true
    }
  })
The
Start
document already exists in the
activityLogTypes
collection it complains that the
activityLogType
does not exist schema I'm probably doing something wrong, and its likely a n00b error for Mongo, but any help would be suggested.
👀 1
im going back to PG ... Mongo just isnt right for this project
a
Hey Rich, It looks like your query isn’t quite right for the schema you posted. It should look something like this where
activityLogType
is passed the usual configuration object for a relation type:
Copy code
await prisma.activityLog.create({
    data: {
      activityLogType: {
        create: {
          activityLogType: 'Start'
        }
      },
      activityLogMessage: 'Start Seeding',
      activityCompleted: true
    }
  })