denodrivers / sqlite3

The fastest and correct SQLite3 module for Deno runtime
https://jsr.io/@db/sqlite
Apache License 2.0
244 stars 20 forks source link

Support promise #136

Open fushihara opened 3 weeks ago

fushihara commented 3 weeks ago

All the operation APIs are synchronous processes, but I would like to see a modern Promise-based API provided.

DjDeveloperr commented 1 week ago

It is intentional here to offer sync APIs only for performance reasons. SQLite unlike other databases, is in-process and does not involve over the network I/O - which we usually do asynchronously. Here, we only have file I/O, and it's really quick most of the times that making it async manually by offloading the work to another thread only introduces more overhead. SQLite3 C API does not offer any asynchronous API. You can always make a new Web Worker, make an SQLite DB instance in that and operate over messages to make it asynchronous and not block the main thread.

Being asynchronous or not is not a matter of being modern. Sometimes, it's just mostly unnecessary to make something asynchronous. The fastest SQLite3 driver for Node.js is better-sqlite3, it is also sync, and so is bun:sqlite. All three including this project offer very similar sync API. Is the synchronous API causing any problems in your application?