PrismaP
Prismaโ€ข2y agoโ€ข
13 replies
Flurrih

[Prisma][MongoDB][Lucia] Malformed objectID

Hi, Im getting very frustrated with the issue Im getting. I was running google oauth on SQLite, but just remapped into MongoDB. I dont know if its Lucia or Prisma... But Im getting this error:
Inconsistent column data: Malformed ObjectID: invalid character 't' was found at index 0 in the provided hex string: "t6d6pgyzluujpbeawuees2f6e6j66el62n43fmd3" for the field 'id'.
    .... {
  code: 'P2023',
  clientVersion: '5.17.0',
  meta: {
    modelName: 'Session',
    message: `Malformed ObjectID: invalid character 't' was found at index 0 in the provided hex string: "t6d6pgyzluujpbeawuees2f6e6j66el62n43fmd3" for the field 'id'.`
  }
}


And this is my schema:

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "mongodb"
  url      = env("DATABASE_URL")
  
}

model User {
  id    String @id @default(auto()) @map("_id") @db.ObjectId
  googleId String @unique
  name String?
  email String @unique
  sessions Session[]
}

model Session {
  id        String   @id @default(auto()) @map("_id") @db.ObjectId
  userId    String @db.ObjectId
  expiresAt DateTime

  user      User     @relation(references: [id], fields: [userId], onDelete: Cascade)
}


Anyone has idea how to fix this issue? ๐Ÿ™‚ Tried many things, but nothing worked so far.
Was this page helpful?