inferSelect doesnt take into account defaults in schema
you can see createdAt has default
12 Replies
Which one of the columns you think has a problem?
updatedAt: integer('updated_at', { mode: 'timestamp_ms' })
.notNull()
.default(sql
CURRENT_TIMESTAMP
),
should be optional typeYou are probably looking for
$inferInsert
, that will give you the type for insert, where all columns that have default are optionalah ok thx
its happy
hey guys im trying to insert start_dtime and end_dtime fields as integers. im trying the attached code. but i run into this error.
Types of property 'start_dtime' are incompatible.
Type 'number' is not assignable to type 'SQL<unknown> | Placeholder<string, any> | Date | null | undefined'.
i have attached both my schema and the code.
can someone help me with this.
When you use
{ mode: 'timestamp_ms' }
, that column now accepts a Date object, and drizzle will run .getTime()
for youbut it is an integer field right? how can i modify my code? any suggestions?
Just remove
.getTime()
from start_date and end_dateok ill try and get back
Just let it be a Date object
yes it works. thank you.