fdarian / prisma-generator-drizzle

A Prisma generator for generating Drizzle schema with ease
88 stars 10 forks source link

Custom date modes? #45

Closed Jonatthu closed 2 months ago

Jonatthu commented 2 months ago

Default output is:

  latestMessageCreatedAt: timestamp('latestMessageCreatedAt', { mode: 'date', precision: 3 })
    .defaultNow()
    .notNull(),

How do I change it to:

  latestMessageCreatedAt: timestamp('latestMessageCreatedAt', { mode: 'string', precision: 3 })
    .defaultNow()
    .notNull(),

or modify the options?

fdarian commented 2 months ago

This can be done

fdarian commented 2 months ago

@Jonatthu, apologize for the delayed response. I have just released version 0.7.0 where you can specify dateMode to "string" within the generator config. Kindly take a look at it.

Jonatthu commented 2 months ago

No apologies needed, indeed thanks a lot for the changes and the feature!

Jonatthu commented 2 months ago

Anyway just to change it at the field level instead of global level?

fdarian commented 2 months ago

Anyway just to change it at the field level instead of global level?

Released 0.7.1 with field-level support, docs coming soon

model User {
  ...
  /// drizzle.dateMode string
  stringDate DateTime
  ...
}
Jonatthu commented 2 months ago

Just tested it and it's working fine!