prisma type error on union type stored as json

I am trying to convert my Cloud Firestore project to supabase due to some issues I have had with transactions. I have the following types in my code:

export interface RoundOptions {
  name: string;
  scoreToWin: number;
}

export interface BracketOptions {
  name: string;
  defaultScoreToWin: number;
  rounds: RoundOptions[];
}

export interface SingleEliminationOptions {
  type: "single_elimination";
  winAnnotations?: string[];
  brackets: [BracketOptions];
}

export interface DoubleEliminationOptions {
  type: "double_elimination";
  winAnnotations?: string[];
  brackets: [BracketOptions, BracketOptions];
}

export type FormatOptions = SingleEliminationOptions | DoubleEliminationOptions;


And this is my prisma schema I am using for experimentation:
model Tournament {
  id   String @id
  data Json
}


In my code I am trying to do:
      await ctx.prisma.tournament.create({
        data: {
          id: tournament.id,
          data: tournament.formatOptions, // This hsa the type FormatOptions
        },
      });


But I am getting this error. Can someone help me understand whats going wrong?
image.png
Solution
Figured it out. In case anybody cares, prisma requires types not interfaces to make this work
Was this page helpful?