How can I create a JSON field in a model?

Hi,

I'm trying to create a model that has a JSON field (Mainly to store a structured data) but I'm facing an error that I can't figure it out.

Here are the models:

model User {
  id                      String       @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
  createdAt               DateTime     @default(now())
  updatedAt               DateTime     @default(now())
  email                   String       @unique
  emailVerified           Boolean      @default(false)
  googleId                String       @unique
  displayName             String
  firstName               String
  lastName                String
  profilePicture          String
  receiveMarketingEmails  Boolean      @default(false)
  QRCodes                 QRCode[]
  quota                   Int          @default(10)
}

model QRCode {
  id                      String       @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
  user                    User?        @relation(fields: [userId], references: [id])
  userId                  String       @db.Uuid
  createdAt               DateTime     @default(now())
  updatedAt               DateTime     @default(now())
  key                     String       @unique
  redirectURL             String?
  isActive                Boolean      @default(false)
  description             String?
  Scans                   Scan[]
  scansCount              Int          @default(0)
}

model Scan {
  id                      String       @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
  qrCode                  QRCode?      @relation(fields: [qrCodeId], references: [id])
  qrCodeId                String       @db.Uuid
  createdAt               DateTime     @default(now())
  geoLocationData         Json?
}


When I try to start Wasp I get the following error. If I do not create the FK between Scan and QRCode it works fine.

Thanks in advance!
Was this page helpful?