Type error inserting 'new Date()' into 'time' type schema.
Driving me up the wall this a bit.
my schema
my insert
type error:
š«
Any ideas?
5 Replies
Why does it want the input to be a string š¤
'timestamp' works ok (no type errors)
but gives me '1970-01-20 14:30:39'
which is why I was trying out other types
ok the timecode I was getting needed to be *1000 and the insert using "on conflict" wasnt working properly, so it wasnt updating when I was debugging š
Try: await db.insert(metalPrices).values({
metal: "FOO",
time: sql
CURTIME()
,
});Oh nice! thanks
Thanks this is all working now!
how can i compare a timestamp to a current time
like gt(schema.timestamp, new Date())
You need convert the new Date() in a string format like that: 2023-08-31T20:11:36.159908, or you can calculate the current time in your database, for example: gt(schema.timestamp, sql
NOW()
)