fdarian/prisma-generator-drizzle

Typed JSON?

Opened this issue · 2 comments

sgup commented

Hi, is there a way to support typed JSON's ?

https://www.prisma.io/docs/orm/prisma-client/special-fields-and-types/working-with-json-fields#typed-json

I added custom types in my drizzle schema (https://orm.drizzle.team/docs/column-types/pg#jsonb), but unfortunately they get overwritten with every change/generate.

You can use drizzle.custom directive for now. Please let me know how the syntax feels.

sgup commented

Hmm, not working for me:

schema.prisma

  /// drizzle.custom {
  ///   "$type": "{ month: string, min: number, max: number }[]",
  /// }
  tempRanges Json?

I'm trying to generate this in drizzle.schema:

tempRanges: jsonb("tempRanges").$type<{ month: string, min: number, max: number }[]>(),

I tried wrapping with <> as well in the comment.

image