Skip to content

Commit 872ce0b

Browse files
add open factory example
1 parent 0acfd2d commit 872ce0b

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

packages/capacitor/README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ npx cap sync
4242

4343
## Usage
4444

45-
```typescript
45+
```javascript
4646
import { PowerSyncDatabase } from '@powersync/capacitor';
4747
// Import general components from the Web SDK package
4848
import { Schema } from '@powersync/web';
@@ -51,13 +51,26 @@ import { Schema } from '@powersync/web';
5151
* and use the appropriate database drivers.
5252
*/
5353
const db = new PowerSyncDatabase({
54-
schema: new Schema({...})
54+
schema: new Schema({...}),
55+
database: {
56+
dbFilename: "mydatabase.sqlite"
57+
}
5558
});
5659
```
5760

5861
- On Android and iOS, this SDK uses [Capacitor Community SQLite](https://github.com/capacitor-community/sqlite) for native database access.
5962
- On web, it falls back to the [PowerSync Web SDK](https://www.npmjs.com/package/@powersync/web).
6063

64+
When using custom database factories, be sure to specify the `CapacitorSQLiteOpenFactory` for Capacitor platforms.
65+
66+
```javascript
67+
const db = new PowerSyncDatabase({
68+
schema: new Schema({...}),
69+
database: isWeb ? new WASQLiteOpenFactory({dbFilename: "mydb.sqlite"}) :
70+
new CapacitorSQLiteOpenFactory({dbFilename: "mydb.sqlite"})
71+
});
72+
```
73+
6174
## Platform Support
6275

6376
- **Android**: Uses native SQLite via Capacitor Community SQLite.

0 commit comments

Comments
 (0)