Open herefishyfish opened 1 year ago
Just a quick comment. I used the SQLite C APIs for a Swift project yesterday and it wasn't too harrowing.
I think offering APIs that are 1:1 with the C APIs might be sensible just because they're ready-documented and there are plenty of existing examples for them out there. If providing direct V8 bindings seems hard, could manually map them out instead. Though would have to be careful about needless copies of data. NativeScript JSI may come in handy (and could actually make use of the existing JSI code in react-native-quick-sqlite).
But its true that the C API feels particularly unjavascripty and so may be intimidating. The hard part is deciding the right abstraction for it. react-native-quick-sqlite does seem loved by the community and successfully used, so it's a perfectly good starting point.
Any plans to support
sqlite3_update_hook
? This would make it compatible with libraries like tinybase
Yep, for the current Android/iOS implementations without "metal" we should already be able to directly access those calls if they're provided by the platform. I think moving forward with the "metal" build I'll expose as many of the direct calls to the C implementation as I can. Having the abstractions in C++ would probably yield slightly better results, but we're probably talking in nanoseconds.
Overview
This repository is designed to consolidate various API layers for SQLite into a unified interface that can seamlessly transition between embedded and system APIs. One of the biggest challenges is the absence of a standard approach towards this goal. Numerous frameworks including Web, React Native, Capacitor, Cordova, and various existing NativeScript implementations have developed their own solutions. Previously, I was aligning our efforts with the React Native Quick SQLite API design. However, I've reconsidered this path as it may not be the best approach.
API Proposal
This is the type for the options argument in the class constructor. It contains properties that determine how the SQLite database is opened.
SQLite Class
This class encapsulates all interactions with the SQLite database, with the instance being instantiated by the constructor
Considerations
Alternatives
The proposed SQLite class and API provides a middle ground. It provides a user-friendly and idiomatic JavaScript API while also exposing the power and flexibility of SQLite. It handles the details of the V8 and SQLite integration, freeing developers from the need to write low-level code or deal directly with the SQLite C API. This makes it a convenient and effective solution for most NativeScript developers.
References:
NativeScript
React Native
Capacitor
Cordova