ulixee / hero

The web browser built for scraping
MIT License
649 stars 32 forks source link

Update date types for SocketsTable.ts #228

Closed GlenDC closed 1 year ago

GlenDC commented 1 year ago

These types are incorrect. In reality they are epoch (ms) timestamps, making it now a bit had to use them (e.g. need to now use as unknown as number from within a Ts codebase).

blakebyrnes commented 1 year ago

SQLite doesn't have any notion of a Date, so to convert the records back out, you need to override get/all to read them to dates when a record is read from the db. Seeing as this is kind of just internal stuff, I haven't dedicated a TON of time to improving our db access, and I didn't want to pull in a big deep like Prisma. So a lot of times I'll just add a static converter and call that outside the Table class, or I'll override .all() with a conversion in there.

GlenDC commented 1 year ago

Ok, so going to close this and then just accept it for now, most of it works for me as-is, so not planning to spend a lot of time one it.

Just found it odd, as the resources db their timestamps are correclty labeled as numbers, so felt like an inconsistency of me, but ok, fair enough.