File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ npx cap sync
42
42
43
43
## Usage
44
44
45
- ``` typescript
45
+ ``` javascript
46
46
import { PowerSyncDatabase } from ' @powersync/capacitor' ;
47
47
// Import general components from the Web SDK package
48
48
import { Schema } from ' @powersync/web' ;
@@ -51,13 +51,26 @@ import { Schema } from '@powersync/web';
51
51
* and use the appropriate database drivers.
52
52
*/
53
53
const db = new PowerSyncDatabase ({
54
- schema: new Schema ({... })
54
+ schema: new Schema ({... }),
55
+ database: {
56
+ dbFilename: " mydatabase.sqlite"
57
+ }
55
58
});
56
59
```
57
60
58
61
- On Android and iOS, this SDK uses [ Capacitor Community SQLite] ( https://github.com/capacitor-community/sqlite ) for native database access.
59
62
- On web, it falls back to the [ PowerSync Web SDK] ( https://www.npmjs.com/package/@powersync/web ) .
60
63
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
+
61
74
## Platform Support
62
75
63
76
- ** Android** : Uses native SQLite via Capacitor Community SQLite.
You can’t perform that action at this time.
0 commit comments