drizzle-orm icon indicating copy to clipboard operation
drizzle-orm copied to clipboard

[FEATURE]: default() should accept a function generator

Open michealroberts opened this issue 2 years ago • 1 comments

Describe want to want

Let's say I wanted to create a Primary Key that took by default a ulid as a generator whenever a new record was added:

We should be able to do something like:

import { ulid } from 'ulid'

import { sqliteTable, text } from 'drizzle-orm/sqlite-core'

export const bodies = sqliteTable('bodies', {
  id: text('id').primaryKey().default(ulid)
})

Without the type system asking for a default string. I could use as ulid(), but this would obviously hard set the default for all records ...

michealroberts avatar May 17 '23 16:05 michealroberts

connected to #556

AndriiSherman avatar May 18 '23 18:05 AndriiSherman

Duplicate of #304?

danielsharvey avatar Jun 18 '23 07:06 danielsharvey

any update about it?

emersonlaurentino avatar Jun 21 '23 20:06 emersonlaurentino

Will close this issue in favour of #304

AndriiSherman avatar Jul 23 '23 18:07 AndriiSherman