-
Notifications
You must be signed in to change notification settings - Fork 56
Capacitor Community SQLite #708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: b161d93 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The future is now! With version 0.4.5 of the core extension, you can:
|
|
||
## Examples | ||
|
||
See the [`demos/example-capacitor/`](https://github.com/journeyapps/powersync-react-native-sdk/blob/capacitor-sdk/demos/example-capacitor/README.md#L1) directory for a working example. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: Need to update this before merging
|
||
export const AppSchema = new Schema({ | ||
customers | ||
lists: customers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: Need to revert this. This makes testing easier for me :D
Some basic benchmark comparisons were ran on an Android Emulator + iPhone Simulator. const now = performance.now();
for (let i = 0; i < 1_000; i++) {
await powerSync.execute('INSERT INTO customers (id, name) VALUES (uuid(), ?)', [`Customer`]);
}
const end = performance.now();
For general mobile comparisons, see https://www.powersync.com/blog/react-native-database-performance-comparison |
Overview
Theoretically, one should be able to use the PowerSync Web SDK in Capacitor Webviews. Recent support items have shown that while this works in practice, the experience is not very stable in some circumstances.
This uses https://github.com/capacitor-community/sqlite as the SQLite driver for PowerSync - with the main aim to target iOS and Android platforms (only iOS has been tested so far).
The Capacitor Community SQLite package currently poses some challenges for PowerSync's use-case:
Unhandled Promise Rejection: Error: "CapacitorSQLite.loadExtension()" is not implemented on ios
execute
methods.We can work around most of these limitations.
Extension Loading
This PR adds a Capacitor Plugin which includes the PowerSync Rust core into a project. We can then register a static SQLite auto extension. We use the low level C APIs for this.
Update Hooks
We register an update hook implementation internally via our Rust Core implementation.
Query execution differences
This is documented as a limitation of the API.
TODOS
CapacitorSQLiteAdapter
for theDBAdapter
provided to the PowerSync Web SDK. While this does work, it seems messy. We should probably introduce a dedicated Capacitor PowerSyncDatabase constructor.