Re:Show HN: Doculite – Use SQLite as a Document Database
by thenorthbay on Monday August 07, 2023 @07:43PM
(#37042481)
If you use the library on a server in a node.js environment, wouldn't it be useful to fetch data (e.g. Remix / NextJS)?
Besides, I'm not sure if better-sqlite3 offers the listener functionalities I care about. Skimming the docs, it seems it doesn't.
Re:Show HN: Doculite – Use SQLite as a Document Database
by zdragnar on Monday August 07, 2023 @08:21PM
(#37042821)
Listener functionality could be something you'd have to write yourself, I suppose.
As for on the server, no. Sqlite is a c library, not a separate application- the work happens inside the node process. Regardless of how you do it, any call into sqlite is going to block. Adding promises or callbacks on top of that is just wasting CPU cycles, unlike reading from the filesystem or making a network request, where the work is offloaded to a process outside of node (and hence why it makes sense to let node do other things instead of waiting).
In fact, if you synchronously read and write within a single function with no awaits or timeouts in-between, you don't have to worry about atomicity- no other request is being handled in the meantime.
Re:Show HN: Doculite – Use SQLite as a Document Database
by thenorthbay on Tuesday August 08, 2023 @04:03PM
(#37054721)
Yeah interesting. I'm wondering what happens when I'm starting to introduce things from "outside" the system that need async operations, like processing webhooks.
Re:Show HN: Doculite – Use SQLite as a Document Database
by jitl on Monday August 07, 2023 @08:21PM
(#37042819)
better-sqlite3 is orders of magnitude faster than the async SQLite bindings. We found this to be true when testing SQLite options for Notion's desktop app anyways. The "why should I use this" bits sound boastful but are reasonable.
https://github.com/WiseLibs/better-sqlite3#why-should-i-use-...
Re:Show HN: Doculite – Use SQLite as a Document Database
by schemescape on Monday August 07, 2023 @08:25PM
(#37042866)
I assumed they were implementing the Firestore API (which is fairly certain is async).
https://github.com/WiseLibs/better-sqlite3