vors
vors•2y ago

Module: schema | Convex Developer Hub

I was trying to create a timestamp or datetime field in the table schema and to my surprise was not able to find such class on https://docs.convex.dev/api/modules/schema#s .... can we get something to work with times in the schema (for cases other then _createdTime)?
Module: schema | Convex Developer Hub
Utilities for defining the schema of your Convex project.
13 Replies
vors
vorsOP•2y ago
Maybe I should use object ? That seems unsafe / doesn't convey the intent well, lol 🙂
nipunn
nipunn•2y ago
It supports the base datatypes supported by the convex database (https://docs.convex.dev/using/types). _creationTime is stored as milliseconds since unix epoch in the dashboard - we sorta hard code that column as a date. We don't (currently) support a way to mark another column as a date in that sort of way.
vors
vorsOP•2y ago
ok so my use-case is to see when people last opened the site
nipunn
nipunn•2y ago
It's really just eye-candy on the dashboard. It's stored as milliseconds since epoch.
vors
vorsOP•2y ago
I ended up storing the string for that because I also want eye candy! 😆
nipunn
nipunn•2y ago
yes - it's a good idea. Definitely helpful.
vors
vorsOP•2y ago
and don't want to build any UI for this functionality (just look in DB) I think Date is a pretty important type to have first class support for imo
nipunn
nipunn•2y ago
Yes agreed. But it's possible we might be able to solve the main painpoint w/o scoping it all the way up to first class date support. Perhaps we could have some way on the dashboard to "view as timestamp" or something like that if we detect the number to smell like a timestamp. So it's really just eyecandy (just like _creationTime)
vors
vorsOP•2y ago
I see, yeah that would work!
nipunn
nipunn•2y ago
Are there other non-dashboard ways in which date columns might be helpful like this?
vors
vorsOP•2y ago
I don't know enough about javascript to have an insights here. If you tell me that milliseconds since epoch is good enough for _createdTime, I trust you 🙂 that it's good enough for other cases
nipunn
nipunn•2y ago
I'll write something down. Maybe we can make something work. your workaround of storing as a string should be pretty good in the meantime
vors
vorsOP•2y ago
I guess one pet peeve with my current approach: I had to store the string in Pacific Timezone for the usability for us. But that just feels wrong as an engineering thing 🙂 Times should not be in Pacific Timezone

Did you find this page helpful?