tinybase 5.0.0-beta.22 → 5.0.0-beta.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/@types/mergeable-store/index.d.cts +77 -11
- package/@types/mergeable-store/index.d.ts +77 -11
- package/@types/mergeable-store/with-schemas/index.d.cts +96 -11
- package/@types/mergeable-store/with-schemas/index.d.ts +96 -11
- package/@types/persisters/index.d.cts +0 -1
- package/@types/persisters/index.d.ts +0 -1
- package/@types/persisters/persister-expo-sqlite/index.d.cts +36 -40
- package/@types/persisters/persister-expo-sqlite/index.d.ts +36 -40
- package/@types/persisters/persister-expo-sqlite/with-schemas/index.d.cts +36 -40
- package/@types/persisters/persister-expo-sqlite/with-schemas/index.d.ts +36 -40
- package/@types/persisters/with-schemas/index.d.cts +0 -1
- package/@types/persisters/with-schemas/index.d.ts +0 -1
- package/cjs/es6/index.cjs +3 -3
- package/cjs/es6/mergeable-store/index.cjs +2 -2
- package/cjs/es6/mergeable-store/with-schemas/index.cjs +2 -2
- package/cjs/es6/min/index.cjs +1 -1
- package/cjs/es6/min/index.cjs.gz +0 -0
- package/cjs/es6/min/mergeable-store/index.cjs +1 -1
- package/cjs/es6/min/mergeable-store/index.cjs.gz +0 -0
- package/cjs/es6/min/mergeable-store/with-schemas/index.cjs +1 -1
- package/cjs/es6/min/mergeable-store/with-schemas/index.cjs.gz +0 -0
- package/cjs/es6/min/persisters/persister-expo-sqlite/index.cjs +1 -1
- package/cjs/es6/min/persisters/persister-expo-sqlite/index.cjs.gz +0 -0
- package/cjs/es6/min/persisters/persister-expo-sqlite/with-schemas/index.cjs +1 -1
- package/cjs/es6/min/persisters/persister-expo-sqlite/with-schemas/index.cjs.gz +0 -0
- package/cjs/es6/min/synchronizers/index.cjs +1 -1
- package/cjs/es6/min/synchronizers/index.cjs.gz +0 -0
- package/cjs/es6/min/synchronizers/synchronizer-local/index.cjs +1 -1
- package/cjs/es6/min/synchronizers/synchronizer-local/index.cjs.gz +0 -0
- package/cjs/es6/min/synchronizers/synchronizer-local/with-schemas/index.cjs +1 -1
- package/cjs/es6/min/synchronizers/synchronizer-local/with-schemas/index.cjs.gz +0 -0
- package/cjs/es6/min/synchronizers/synchronizer-ws-client/index.cjs +1 -1
- package/cjs/es6/min/synchronizers/synchronizer-ws-client/index.cjs.gz +0 -0
- package/cjs/es6/min/synchronizers/synchronizer-ws-client/with-schemas/index.cjs +1 -1
- package/cjs/es6/min/synchronizers/synchronizer-ws-client/with-schemas/index.cjs.gz +0 -0
- package/cjs/es6/min/synchronizers/with-schemas/index.cjs +1 -1
- package/cjs/es6/min/synchronizers/with-schemas/index.cjs.gz +0 -0
- package/cjs/es6/min/with-schemas/index.cjs +1 -1
- package/cjs/es6/min/with-schemas/index.cjs.gz +0 -0
- package/cjs/es6/persisters/persister-expo-sqlite/index.cjs +7 -2
- package/cjs/es6/persisters/persister-expo-sqlite/with-schemas/index.cjs +7 -2
- package/cjs/es6/synchronizers/index.cjs +1 -1
- package/cjs/es6/synchronizers/synchronizer-local/index.cjs +1 -1
- package/cjs/es6/synchronizers/synchronizer-local/with-schemas/index.cjs +1 -1
- package/cjs/es6/synchronizers/synchronizer-ws-client/index.cjs +1 -1
- package/cjs/es6/synchronizers/synchronizer-ws-client/with-schemas/index.cjs +1 -1
- package/cjs/es6/synchronizers/with-schemas/index.cjs +1 -1
- package/cjs/es6/with-schemas/index.cjs +3 -3
- package/cjs/index.cjs +3 -3
- package/cjs/mergeable-store/index.cjs +2 -2
- package/cjs/mergeable-store/with-schemas/index.cjs +2 -2
- package/cjs/min/index.cjs +1 -1
- package/cjs/min/index.cjs.gz +0 -0
- package/cjs/min/mergeable-store/index.cjs +1 -1
- package/cjs/min/mergeable-store/index.cjs.gz +0 -0
- package/cjs/min/mergeable-store/with-schemas/index.cjs +1 -1
- package/cjs/min/mergeable-store/with-schemas/index.cjs.gz +0 -0
- package/cjs/min/persisters/persister-expo-sqlite/index.cjs +1 -1
- package/cjs/min/persisters/persister-expo-sqlite/index.cjs.gz +0 -0
- package/cjs/min/persisters/persister-expo-sqlite/with-schemas/index.cjs +1 -1
- package/cjs/min/persisters/persister-expo-sqlite/with-schemas/index.cjs.gz +0 -0
- package/cjs/min/synchronizers/index.cjs +1 -1
- package/cjs/min/synchronizers/index.cjs.gz +0 -0
- package/cjs/min/synchronizers/synchronizer-local/index.cjs +1 -1
- package/cjs/min/synchronizers/synchronizer-local/index.cjs.gz +0 -0
- package/cjs/min/synchronizers/synchronizer-local/with-schemas/index.cjs +1 -1
- package/cjs/min/synchronizers/synchronizer-local/with-schemas/index.cjs.gz +0 -0
- package/cjs/min/synchronizers/synchronizer-ws-client/index.cjs +1 -1
- package/cjs/min/synchronizers/synchronizer-ws-client/index.cjs.gz +0 -0
- package/cjs/min/synchronizers/synchronizer-ws-client/with-schemas/index.cjs +1 -1
- package/cjs/min/synchronizers/synchronizer-ws-client/with-schemas/index.cjs.gz +0 -0
- package/cjs/min/synchronizers/with-schemas/index.cjs +1 -1
- package/cjs/min/synchronizers/with-schemas/index.cjs.gz +0 -0
- package/cjs/min/with-schemas/index.cjs +1 -1
- package/cjs/min/with-schemas/index.cjs.gz +0 -0
- package/cjs/persisters/persister-expo-sqlite/index.cjs +7 -3
- package/cjs/persisters/persister-expo-sqlite/with-schemas/index.cjs +7 -3
- package/cjs/synchronizers/index.cjs +1 -1
- package/cjs/synchronizers/synchronizer-local/index.cjs +1 -1
- package/cjs/synchronizers/synchronizer-local/with-schemas/index.cjs +1 -1
- package/cjs/synchronizers/synchronizer-ws-client/index.cjs +1 -1
- package/cjs/synchronizers/synchronizer-ws-client/with-schemas/index.cjs +1 -1
- package/cjs/synchronizers/with-schemas/index.cjs +1 -1
- package/cjs/with-schemas/index.cjs +3 -3
- package/es6/index.js +3 -3
- package/es6/mergeable-store/index.js +2 -2
- package/es6/mergeable-store/with-schemas/index.js +2 -2
- package/es6/min/index.js +1 -1
- package/es6/min/index.js.gz +0 -0
- package/es6/min/mergeable-store/index.js +1 -1
- package/es6/min/mergeable-store/index.js.gz +0 -0
- package/es6/min/mergeable-store/with-schemas/index.js +1 -1
- package/es6/min/mergeable-store/with-schemas/index.js.gz +0 -0
- package/es6/min/persisters/persister-expo-sqlite/index.js +1 -1
- package/es6/min/persisters/persister-expo-sqlite/index.js.gz +0 -0
- package/es6/min/persisters/persister-expo-sqlite/with-schemas/index.js +1 -1
- package/es6/min/persisters/persister-expo-sqlite/with-schemas/index.js.gz +0 -0
- package/es6/min/synchronizers/index.js +1 -1
- package/es6/min/synchronizers/index.js.gz +0 -0
- package/es6/min/synchronizers/synchronizer-local/index.js +1 -1
- package/es6/min/synchronizers/synchronizer-local/index.js.gz +0 -0
- package/es6/min/synchronizers/synchronizer-local/with-schemas/index.js +1 -1
- package/es6/min/synchronizers/synchronizer-local/with-schemas/index.js.gz +0 -0
- package/es6/min/synchronizers/synchronizer-ws-client/index.js +1 -1
- package/es6/min/synchronizers/synchronizer-ws-client/index.js.gz +0 -0
- package/es6/min/synchronizers/synchronizer-ws-client/with-schemas/index.js +1 -1
- package/es6/min/synchronizers/synchronizer-ws-client/with-schemas/index.js.gz +0 -0
- package/es6/min/synchronizers/with-schemas/index.js +1 -1
- package/es6/min/synchronizers/with-schemas/index.js.gz +0 -0
- package/es6/min/with-schemas/index.js +1 -1
- package/es6/min/with-schemas/index.js.gz +0 -0
- package/es6/persisters/persister-expo-sqlite/index.js +5 -2
- package/es6/persisters/persister-expo-sqlite/with-schemas/index.js +5 -2
- package/es6/synchronizers/index.js +1 -1
- package/es6/synchronizers/synchronizer-local/index.js +1 -1
- package/es6/synchronizers/synchronizer-local/with-schemas/index.js +1 -1
- package/es6/synchronizers/synchronizer-ws-client/index.js +1 -1
- package/es6/synchronizers/synchronizer-ws-client/with-schemas/index.js +1 -1
- package/es6/synchronizers/with-schemas/index.js +1 -1
- package/es6/with-schemas/index.js +3 -3
- package/index.js +3 -3
- package/mergeable-store/index.js +2 -2
- package/mergeable-store/with-schemas/index.js +2 -2
- package/min/index.js +1 -1
- package/min/index.js.gz +0 -0
- package/min/mergeable-store/index.js +1 -1
- package/min/mergeable-store/index.js.gz +0 -0
- package/min/mergeable-store/with-schemas/index.js +1 -1
- package/min/mergeable-store/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-expo-sqlite/index.js +1 -1
- package/min/persisters/persister-expo-sqlite/index.js.gz +0 -0
- package/min/persisters/persister-expo-sqlite/with-schemas/index.js +1 -1
- package/min/persisters/persister-expo-sqlite/with-schemas/index.js.gz +0 -0
- package/min/synchronizers/index.js +1 -1
- package/min/synchronizers/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-local/index.js +1 -1
- package/min/synchronizers/synchronizer-local/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-local/with-schemas/index.js +1 -1
- package/min/synchronizers/synchronizer-local/with-schemas/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-client/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-client/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-client/with-schemas/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-client/with-schemas/index.js.gz +0 -0
- package/min/synchronizers/with-schemas/index.js +1 -1
- package/min/synchronizers/with-schemas/index.js.gz +0 -0
- package/min/with-schemas/index.js +1 -1
- package/min/with-schemas/index.js.gz +0 -0
- package/package.json +9 -112
- package/persisters/persister-expo-sqlite/index.js +5 -3
- package/persisters/persister-expo-sqlite/with-schemas/index.js +5 -3
- package/readme.md +2 -2
- package/releases.md +2 -2
- package/synchronizers/index.js +1 -1
- package/synchronizers/synchronizer-local/index.js +1 -1
- package/synchronizers/synchronizer-local/with-schemas/index.js +1 -1
- package/synchronizers/synchronizer-ws-client/index.js +1 -1
- package/synchronizers/synchronizer-ws-client/with-schemas/index.js +1 -1
- package/synchronizers/with-schemas/index.js +1 -1
- package/umd/es6/index.js +3 -3
- package/umd/es6/mergeable-store/index.js +2 -2
- package/umd/es6/mergeable-store/with-schemas/index.js +2 -2
- package/umd/es6/min/index.js +1 -1
- package/umd/es6/min/index.js.gz +0 -0
- package/umd/es6/min/mergeable-store/index.js +1 -1
- package/umd/es6/min/mergeable-store/index.js.gz +0 -0
- package/umd/es6/min/mergeable-store/with-schemas/index.js +1 -1
- package/umd/es6/min/mergeable-store/with-schemas/index.js.gz +0 -0
- package/umd/es6/min/persisters/persister-expo-sqlite/index.js +1 -1
- package/umd/es6/min/persisters/persister-expo-sqlite/index.js.gz +0 -0
- package/umd/es6/min/persisters/persister-expo-sqlite/with-schemas/index.js +1 -1
- package/umd/es6/min/persisters/persister-expo-sqlite/with-schemas/index.js.gz +0 -0
- package/umd/es6/min/synchronizers/index.js +1 -1
- package/umd/es6/min/synchronizers/index.js.gz +0 -0
- package/umd/es6/min/synchronizers/synchronizer-local/index.js +1 -1
- package/umd/es6/min/synchronizers/synchronizer-local/index.js.gz +0 -0
- package/umd/es6/min/synchronizers/synchronizer-local/with-schemas/index.js +1 -1
- package/umd/es6/min/synchronizers/synchronizer-local/with-schemas/index.js.gz +0 -0
- package/umd/es6/min/synchronizers/synchronizer-ws-client/index.js +1 -1
- package/umd/es6/min/synchronizers/synchronizer-ws-client/index.js.gz +0 -0
- package/umd/es6/min/synchronizers/synchronizer-ws-client/with-schemas/index.js +1 -1
- package/umd/es6/min/synchronizers/synchronizer-ws-client/with-schemas/index.js.gz +0 -0
- package/umd/es6/min/synchronizers/with-schemas/index.js +1 -1
- package/umd/es6/min/synchronizers/with-schemas/index.js.gz +0 -0
- package/umd/es6/min/with-schemas/index.js +1 -1
- package/umd/es6/min/with-schemas/index.js.gz +0 -0
- package/umd/es6/persisters/persister-expo-sqlite/index.js +12 -6
- package/umd/es6/persisters/persister-expo-sqlite/with-schemas/index.js +12 -6
- package/umd/es6/synchronizers/index.js +1 -1
- package/umd/es6/synchronizers/synchronizer-local/index.js +1 -1
- package/umd/es6/synchronizers/synchronizer-local/with-schemas/index.js +1 -1
- package/umd/es6/synchronizers/synchronizer-ws-client/index.js +1 -1
- package/umd/es6/synchronizers/synchronizer-ws-client/with-schemas/index.js +1 -1
- package/umd/es6/synchronizers/with-schemas/index.js +1 -1
- package/umd/es6/with-schemas/index.js +3 -3
- package/umd/index.js +3 -3
- package/umd/mergeable-store/index.js +2 -2
- package/umd/mergeable-store/with-schemas/index.js +2 -2
- package/umd/min/index.js +1 -1
- package/umd/min/index.js.gz +0 -0
- package/umd/min/mergeable-store/index.js +1 -1
- package/umd/min/mergeable-store/index.js.gz +0 -0
- package/umd/min/mergeable-store/with-schemas/index.js +1 -1
- package/umd/min/mergeable-store/with-schemas/index.js.gz +0 -0
- package/umd/min/persisters/persister-expo-sqlite/index.js +1 -1
- package/umd/min/persisters/persister-expo-sqlite/index.js.gz +0 -0
- package/umd/min/persisters/persister-expo-sqlite/with-schemas/index.js +1 -1
- package/umd/min/persisters/persister-expo-sqlite/with-schemas/index.js.gz +0 -0
- package/umd/min/synchronizers/index.js +1 -1
- package/umd/min/synchronizers/index.js.gz +0 -0
- package/umd/min/synchronizers/synchronizer-local/index.js +1 -1
- package/umd/min/synchronizers/synchronizer-local/index.js.gz +0 -0
- package/umd/min/synchronizers/synchronizer-local/with-schemas/index.js +1 -1
- package/umd/min/synchronizers/synchronizer-local/with-schemas/index.js.gz +0 -0
- package/umd/min/synchronizers/synchronizer-ws-client/index.js +1 -1
- package/umd/min/synchronizers/synchronizer-ws-client/index.js.gz +0 -0
- package/umd/min/synchronizers/synchronizer-ws-client/with-schemas/index.js +1 -1
- package/umd/min/synchronizers/synchronizer-ws-client/with-schemas/index.js.gz +0 -0
- package/umd/min/synchronizers/with-schemas/index.js +1 -1
- package/umd/min/synchronizers/with-schemas/index.js.gz +0 -0
- package/umd/min/with-schemas/index.js +1 -1
- package/umd/min/with-schemas/index.js.gz +0 -0
- package/umd/persisters/persister-expo-sqlite/index.js +12 -7
- package/umd/persisters/persister-expo-sqlite/with-schemas/index.js +12 -7
- package/umd/synchronizers/index.js +1 -1
- package/umd/synchronizers/synchronizer-local/index.js +1 -1
- package/umd/synchronizers/synchronizer-local/with-schemas/index.js +1 -1
- package/umd/synchronizers/synchronizer-ws-client/index.js +1 -1
- package/umd/synchronizers/synchronizer-ws-client/with-schemas/index.js +1 -1
- package/umd/synchronizers/with-schemas/index.js +1 -1
- package/umd/with-schemas/index.js +3 -3
- package/with-schemas/index.js +3 -3
- package/@types/persisters/persister-expo-sqlite-next/index.d.cts +0 -187
- package/@types/persisters/persister-expo-sqlite-next/index.d.ts +0 -187
- package/@types/persisters/persister-expo-sqlite-next/with-schemas/index.d.cts +0 -206
- package/@types/persisters/persister-expo-sqlite-next/with-schemas/index.d.ts +0 -206
- package/cjs/es6/min/persisters/persister-expo-sqlite-next/index.cjs +0 -1
- package/cjs/es6/min/persisters/persister-expo-sqlite-next/index.cjs.gz +0 -0
- package/cjs/es6/min/persisters/persister-expo-sqlite-next/with-schemas/index.cjs +0 -1
- package/cjs/es6/min/persisters/persister-expo-sqlite-next/with-schemas/index.cjs.gz +0 -0
- package/cjs/es6/persisters/persister-expo-sqlite-next/index.cjs +0 -1253
- package/cjs/es6/persisters/persister-expo-sqlite-next/with-schemas/index.cjs +0 -1253
- package/cjs/min/persisters/persister-expo-sqlite-next/index.cjs +0 -1
- package/cjs/min/persisters/persister-expo-sqlite-next/index.cjs.gz +0 -0
- package/cjs/min/persisters/persister-expo-sqlite-next/with-schemas/index.cjs +0 -1
- package/cjs/min/persisters/persister-expo-sqlite-next/with-schemas/index.cjs.gz +0 -0
- package/cjs/persisters/persister-expo-sqlite-next/index.cjs +0 -926
- package/cjs/persisters/persister-expo-sqlite-next/with-schemas/index.cjs +0 -926
- package/es6/min/persisters/persister-expo-sqlite-next/index.js +0 -1
- package/es6/min/persisters/persister-expo-sqlite-next/index.js.gz +0 -0
- package/es6/min/persisters/persister-expo-sqlite-next/with-schemas/index.js +0 -1
- package/es6/min/persisters/persister-expo-sqlite-next/with-schemas/index.js.gz +0 -0
- package/es6/persisters/persister-expo-sqlite-next/index.js +0 -1251
- package/es6/persisters/persister-expo-sqlite-next/with-schemas/index.js +0 -1251
- package/min/persisters/persister-expo-sqlite-next/index.js +0 -1
- package/min/persisters/persister-expo-sqlite-next/index.js.gz +0 -0
- package/min/persisters/persister-expo-sqlite-next/with-schemas/index.js +0 -1
- package/min/persisters/persister-expo-sqlite-next/with-schemas/index.js.gz +0 -0
- package/persisters/persister-expo-sqlite-next/index.js +0 -924
- package/persisters/persister-expo-sqlite-next/with-schemas/index.js +0 -924
- package/umd/es6/min/persisters/persister-expo-sqlite-next/index.js +0 -1
- package/umd/es6/min/persisters/persister-expo-sqlite-next/index.js.gz +0 -0
- package/umd/es6/min/persisters/persister-expo-sqlite-next/with-schemas/index.js +0 -1
- package/umd/es6/min/persisters/persister-expo-sqlite-next/with-schemas/index.js.gz +0 -0
- package/umd/es6/persisters/persister-expo-sqlite-next/index.js +0 -1293
- package/umd/es6/persisters/persister-expo-sqlite-next/with-schemas/index.js +0 -1293
- package/umd/min/persisters/persister-expo-sqlite-next/index.js +0 -1
- package/umd/min/persisters/persister-expo-sqlite-next/index.js.gz +0 -0
- package/umd/min/persisters/persister-expo-sqlite-next/with-schemas/index.js +0 -1
- package/umd/min/persisters/persister-expo-sqlite-next/with-schemas/index.js.gz +0 -0
- package/umd/persisters/persister-expo-sqlite-next/index.js +0 -957
- package/umd/persisters/persister-expo-sqlite-next/with-schemas/index.js +0 -957
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The persister-expo-sqlite module of the TinyBase project lets you save and
|
|
3
|
-
* load Store data to and from a
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* This module provides a Persister for the legacy version of Expo's
|
|
7
|
-
* [SQLite](https://docs.expo.dev/versions/latest/sdk/sqlite) library. This API
|
|
8
|
-
* should be used if you are installing the `expo-sqlite` module.
|
|
3
|
+
* load Store data to and from a Expo-SQLite database (in an appropriate React
|
|
4
|
+
* Native environment).
|
|
9
5
|
*
|
|
10
|
-
*
|
|
11
|
-
* (
|
|
12
|
-
*
|
|
6
|
+
* As of TinyBase v5.0, this module provides a Persister for the modern version
|
|
7
|
+
* of Expo's [SQLite](https://docs.expo.dev/versions/latest/sdk/sqlite) library,
|
|
8
|
+
* designated 'next' as of November 2023 and default as v14.0 by June 2024.
|
|
13
9
|
*
|
|
14
|
-
* Note that
|
|
15
|
-
*
|
|
10
|
+
* Note that TinyBase support for the legacy version of Expo-SQLite is no longer
|
|
11
|
+
* available.
|
|
16
12
|
* @see Persisting Data guide
|
|
17
13
|
* @packageDocumentation
|
|
18
14
|
* @module persister-expo-sqlite
|
|
19
|
-
* @since v4.0
|
|
15
|
+
* @since v4.5.0
|
|
20
16
|
*/
|
|
21
17
|
|
|
22
18
|
import type {DatabasePersisterConfig, Persister} from '../index.d.cts';
|
|
@@ -34,7 +30,7 @@ import type {Store} from '../../store/index.d.cts';
|
|
|
34
30
|
* You should use the createExpoSqlitePersister function to create an
|
|
35
31
|
* ExpoSqlitePersister object.
|
|
36
32
|
* @category Persister
|
|
37
|
-
* @since v4.
|
|
33
|
+
* @since v4.5.0
|
|
38
34
|
*/
|
|
39
35
|
export interface ExpoSqlitePersister extends Persister<3> {
|
|
40
36
|
/**
|
|
@@ -48,9 +44,9 @@ export interface ExpoSqlitePersister extends Persister<3> {
|
|
|
48
44
|
* ```js yolo
|
|
49
45
|
* import {createExpoSqlitePersister} from 'tinybase/persisters/persister-expo-sqlite';
|
|
50
46
|
* import {createStore} from 'tinybase';
|
|
51
|
-
* import {
|
|
47
|
+
* import {openDatabaseSync} from 'expo-sqlite';
|
|
52
48
|
*
|
|
53
|
-
* const db =
|
|
49
|
+
* const db = openDatabaseSync('my.db');
|
|
54
50
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
55
51
|
* const persister = createExpoSqlitePersister(store, db, 'my_tinybase');
|
|
56
52
|
*
|
|
@@ -60,7 +56,7 @@ export interface ExpoSqlitePersister extends Persister<3> {
|
|
|
60
56
|
* persister.destroy();
|
|
61
57
|
* ```
|
|
62
58
|
* @category Getter
|
|
63
|
-
* @since v4.
|
|
59
|
+
* @since v4.5.0
|
|
64
60
|
*/
|
|
65
61
|
getDb(): SQLiteDatabase;
|
|
66
62
|
}
|
|
@@ -95,23 +91,23 @@ export interface ExpoSqlitePersister extends Persister<3> {
|
|
|
95
91
|
* JSON serialization).
|
|
96
92
|
* @param onSqlCommand An optional handler called every time the Persister
|
|
97
93
|
* executes a SQL command or query. This is suitable for logging persistence
|
|
98
|
-
* behavior in a development environment
|
|
94
|
+
* behavior in a development environment.
|
|
99
95
|
* @param onIgnoredError An optional handler for the errors that the Persister
|
|
100
96
|
* would otherwise ignore when trying to save or load data. This is suitable for
|
|
101
|
-
* debugging persistence issues in a development environment
|
|
97
|
+
* debugging persistence issues in a development environment.
|
|
102
98
|
* @returns A reference to the new ExpoSqlitePersister object.
|
|
103
99
|
* @example
|
|
104
|
-
* This example creates a ExpoSqlitePersister object and persists the Store
|
|
105
|
-
* local SQLite database as a JSON serialization into the `my_tinybase`
|
|
106
|
-
* It makes a change to the database directly and then reloads it back
|
|
107
|
-
* Store.
|
|
100
|
+
* This example creates a ExpoSqlitePersister object and persists the Store
|
|
101
|
+
* to a local SQLite database as a JSON serialization into the `my_tinybase`
|
|
102
|
+
* table. It makes a change to the database directly and then reloads it back
|
|
103
|
+
* into the Store.
|
|
108
104
|
*
|
|
109
105
|
* ```js yolo
|
|
110
106
|
* import {createExpoSqlitePersister} from 'tinybase/persisters/persister-expo-sqlite';
|
|
111
107
|
* import {createStore} from 'tinybase';
|
|
112
|
-
* import {
|
|
108
|
+
* import {openDatabaseSync} from 'expo-sqlite';
|
|
113
109
|
*
|
|
114
|
-
* const db =
|
|
110
|
+
* const db = openDatabaseSync('my.db');
|
|
115
111
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
116
112
|
* const persister = createExpoSqlitePersister(store, db, 'my_tinybase');
|
|
117
113
|
*
|
|
@@ -120,17 +116,18 @@ export interface ExpoSqlitePersister extends Persister<3> {
|
|
|
120
116
|
*
|
|
121
117
|
* console.log(
|
|
122
118
|
* await new Promise((resolve) =>
|
|
123
|
-
* db.
|
|
119
|
+
* db.allAsync('SELECT * FROM my_tinybase;').then(resolve),
|
|
124
120
|
* ),
|
|
125
121
|
* );
|
|
126
122
|
* // -> [{_id: '_', store: '[{"pets":{"fido":{"species":"dog"}}},{}]'}]
|
|
127
123
|
*
|
|
128
124
|
* await new Promise((resolve) =>
|
|
129
|
-
* db
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
125
|
+
* db
|
|
126
|
+
* .allAsync(
|
|
127
|
+
* 'UPDATE my_tinybase SET store = ' +
|
|
128
|
+
* `'[{"pets":{"felix":{"species":"cat"}}},{}]' WHERE _id = '_';`,
|
|
129
|
+
* )
|
|
130
|
+
* .then(resolve),
|
|
134
131
|
* );
|
|
135
132
|
* await persister.load();
|
|
136
133
|
* console.log(store.getTables());
|
|
@@ -139,15 +136,15 @@ export interface ExpoSqlitePersister extends Persister<3> {
|
|
|
139
136
|
* persister.destroy();
|
|
140
137
|
* ```
|
|
141
138
|
* @example
|
|
142
|
-
* This example creates a ExpoSqlitePersister object and persists the Store
|
|
143
|
-
* local SQLite database with tabular mapping.
|
|
139
|
+
* This example creates a ExpoSqlitePersister object and persists the Store
|
|
140
|
+
* to a local SQLite database with tabular mapping.
|
|
144
141
|
*
|
|
145
142
|
* ```js yolo
|
|
146
143
|
* import {createExpoSqlitePersister} from 'tinybase/persisters/persister-expo-sqlite';
|
|
147
144
|
* import {createStore} from 'tinybase';
|
|
148
|
-
* import {
|
|
145
|
+
* import {openDatabaseSync} from 'expo-sqlite';
|
|
149
146
|
*
|
|
150
|
-
* const db =
|
|
147
|
+
* const db = openDatabaseSync('my.db');
|
|
151
148
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
152
149
|
* const persister = createExpoSqlitePersister(store, db, {
|
|
153
150
|
* mode: 'tabular',
|
|
@@ -157,16 +154,15 @@ export interface ExpoSqlitePersister extends Persister<3> {
|
|
|
157
154
|
* await persister.save();
|
|
158
155
|
* console.log(
|
|
159
156
|
* await new Promise((resolve) =>
|
|
160
|
-
* db.
|
|
157
|
+
* db.allAsync('SELECT * FROM pets;').then(resolve),
|
|
161
158
|
* ),
|
|
162
159
|
* );
|
|
163
160
|
* // -> [{_id: 'fido', species: 'dog'}]
|
|
164
161
|
*
|
|
165
162
|
* await new Promise((resolve) =>
|
|
166
|
-
* db
|
|
167
|
-
* `INSERT INTO pets (_id, species) VALUES ('felix', 'cat')
|
|
168
|
-
* resolve,
|
|
169
|
-
* ),
|
|
163
|
+
* db
|
|
164
|
+
* .allAsync(`INSERT INTO pets (_id, species) VALUES ('felix', 'cat')`)
|
|
165
|
+
* .then(resolve),
|
|
170
166
|
* );
|
|
171
167
|
* await persister.load();
|
|
172
168
|
* console.log(store.getTables());
|
|
@@ -175,7 +171,7 @@ export interface ExpoSqlitePersister extends Persister<3> {
|
|
|
175
171
|
* persister.destroy();
|
|
176
172
|
* ```
|
|
177
173
|
* @category Creation
|
|
178
|
-
* @since v4.0
|
|
174
|
+
* @since v4.5.0
|
|
179
175
|
*/
|
|
180
176
|
export function createExpoSqlitePersister(
|
|
181
177
|
store: Store | MergeableStore,
|
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The persister-expo-sqlite module of the TinyBase project lets you save and
|
|
3
|
-
* load Store data to and from a
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* This module provides a Persister for the legacy version of Expo's
|
|
7
|
-
* [SQLite](https://docs.expo.dev/versions/latest/sdk/sqlite) library. This API
|
|
8
|
-
* should be used if you are installing the `expo-sqlite` module.
|
|
3
|
+
* load Store data to and from a Expo-SQLite database (in an appropriate React
|
|
4
|
+
* Native environment).
|
|
9
5
|
*
|
|
10
|
-
*
|
|
11
|
-
* (
|
|
12
|
-
*
|
|
6
|
+
* As of TinyBase v5.0, this module provides a Persister for the modern version
|
|
7
|
+
* of Expo's [SQLite](https://docs.expo.dev/versions/latest/sdk/sqlite) library,
|
|
8
|
+
* designated 'next' as of November 2023 and default as v14.0 by June 2024.
|
|
13
9
|
*
|
|
14
|
-
* Note that
|
|
15
|
-
*
|
|
10
|
+
* Note that TinyBase support for the legacy version of Expo-SQLite is no longer
|
|
11
|
+
* available.
|
|
16
12
|
* @see Persisting Data guide
|
|
17
13
|
* @packageDocumentation
|
|
18
14
|
* @module persister-expo-sqlite
|
|
19
|
-
* @since v4.0
|
|
15
|
+
* @since v4.5.0
|
|
20
16
|
*/
|
|
21
17
|
|
|
22
18
|
import type {DatabasePersisterConfig, Persister} from '../index.d.ts';
|
|
@@ -34,7 +30,7 @@ import type {Store} from '../../store/index.d.ts';
|
|
|
34
30
|
* You should use the createExpoSqlitePersister function to create an
|
|
35
31
|
* ExpoSqlitePersister object.
|
|
36
32
|
* @category Persister
|
|
37
|
-
* @since v4.
|
|
33
|
+
* @since v4.5.0
|
|
38
34
|
*/
|
|
39
35
|
export interface ExpoSqlitePersister extends Persister<3> {
|
|
40
36
|
/**
|
|
@@ -48,9 +44,9 @@ export interface ExpoSqlitePersister extends Persister<3> {
|
|
|
48
44
|
* ```js yolo
|
|
49
45
|
* import {createExpoSqlitePersister} from 'tinybase/persisters/persister-expo-sqlite';
|
|
50
46
|
* import {createStore} from 'tinybase';
|
|
51
|
-
* import {
|
|
47
|
+
* import {openDatabaseSync} from 'expo-sqlite';
|
|
52
48
|
*
|
|
53
|
-
* const db =
|
|
49
|
+
* const db = openDatabaseSync('my.db');
|
|
54
50
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
55
51
|
* const persister = createExpoSqlitePersister(store, db, 'my_tinybase');
|
|
56
52
|
*
|
|
@@ -60,7 +56,7 @@ export interface ExpoSqlitePersister extends Persister<3> {
|
|
|
60
56
|
* persister.destroy();
|
|
61
57
|
* ```
|
|
62
58
|
* @category Getter
|
|
63
|
-
* @since v4.
|
|
59
|
+
* @since v4.5.0
|
|
64
60
|
*/
|
|
65
61
|
getDb(): SQLiteDatabase;
|
|
66
62
|
}
|
|
@@ -95,23 +91,23 @@ export interface ExpoSqlitePersister extends Persister<3> {
|
|
|
95
91
|
* JSON serialization).
|
|
96
92
|
* @param onSqlCommand An optional handler called every time the Persister
|
|
97
93
|
* executes a SQL command or query. This is suitable for logging persistence
|
|
98
|
-
* behavior in a development environment
|
|
94
|
+
* behavior in a development environment.
|
|
99
95
|
* @param onIgnoredError An optional handler for the errors that the Persister
|
|
100
96
|
* would otherwise ignore when trying to save or load data. This is suitable for
|
|
101
|
-
* debugging persistence issues in a development environment
|
|
97
|
+
* debugging persistence issues in a development environment.
|
|
102
98
|
* @returns A reference to the new ExpoSqlitePersister object.
|
|
103
99
|
* @example
|
|
104
|
-
* This example creates a ExpoSqlitePersister object and persists the Store
|
|
105
|
-
* local SQLite database as a JSON serialization into the `my_tinybase`
|
|
106
|
-
* It makes a change to the database directly and then reloads it back
|
|
107
|
-
* Store.
|
|
100
|
+
* This example creates a ExpoSqlitePersister object and persists the Store
|
|
101
|
+
* to a local SQLite database as a JSON serialization into the `my_tinybase`
|
|
102
|
+
* table. It makes a change to the database directly and then reloads it back
|
|
103
|
+
* into the Store.
|
|
108
104
|
*
|
|
109
105
|
* ```js yolo
|
|
110
106
|
* import {createExpoSqlitePersister} from 'tinybase/persisters/persister-expo-sqlite';
|
|
111
107
|
* import {createStore} from 'tinybase';
|
|
112
|
-
* import {
|
|
108
|
+
* import {openDatabaseSync} from 'expo-sqlite';
|
|
113
109
|
*
|
|
114
|
-
* const db =
|
|
110
|
+
* const db = openDatabaseSync('my.db');
|
|
115
111
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
116
112
|
* const persister = createExpoSqlitePersister(store, db, 'my_tinybase');
|
|
117
113
|
*
|
|
@@ -120,17 +116,18 @@ export interface ExpoSqlitePersister extends Persister<3> {
|
|
|
120
116
|
*
|
|
121
117
|
* console.log(
|
|
122
118
|
* await new Promise((resolve) =>
|
|
123
|
-
* db.
|
|
119
|
+
* db.allAsync('SELECT * FROM my_tinybase;').then(resolve),
|
|
124
120
|
* ),
|
|
125
121
|
* );
|
|
126
122
|
* // -> [{_id: '_', store: '[{"pets":{"fido":{"species":"dog"}}},{}]'}]
|
|
127
123
|
*
|
|
128
124
|
* await new Promise((resolve) =>
|
|
129
|
-
* db
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
125
|
+
* db
|
|
126
|
+
* .allAsync(
|
|
127
|
+
* 'UPDATE my_tinybase SET store = ' +
|
|
128
|
+
* `'[{"pets":{"felix":{"species":"cat"}}},{}]' WHERE _id = '_';`,
|
|
129
|
+
* )
|
|
130
|
+
* .then(resolve),
|
|
134
131
|
* );
|
|
135
132
|
* await persister.load();
|
|
136
133
|
* console.log(store.getTables());
|
|
@@ -139,15 +136,15 @@ export interface ExpoSqlitePersister extends Persister<3> {
|
|
|
139
136
|
* persister.destroy();
|
|
140
137
|
* ```
|
|
141
138
|
* @example
|
|
142
|
-
* This example creates a ExpoSqlitePersister object and persists the Store
|
|
143
|
-
* local SQLite database with tabular mapping.
|
|
139
|
+
* This example creates a ExpoSqlitePersister object and persists the Store
|
|
140
|
+
* to a local SQLite database with tabular mapping.
|
|
144
141
|
*
|
|
145
142
|
* ```js yolo
|
|
146
143
|
* import {createExpoSqlitePersister} from 'tinybase/persisters/persister-expo-sqlite';
|
|
147
144
|
* import {createStore} from 'tinybase';
|
|
148
|
-
* import {
|
|
145
|
+
* import {openDatabaseSync} from 'expo-sqlite';
|
|
149
146
|
*
|
|
150
|
-
* const db =
|
|
147
|
+
* const db = openDatabaseSync('my.db');
|
|
151
148
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
152
149
|
* const persister = createExpoSqlitePersister(store, db, {
|
|
153
150
|
* mode: 'tabular',
|
|
@@ -157,16 +154,15 @@ export interface ExpoSqlitePersister extends Persister<3> {
|
|
|
157
154
|
* await persister.save();
|
|
158
155
|
* console.log(
|
|
159
156
|
* await new Promise((resolve) =>
|
|
160
|
-
* db.
|
|
157
|
+
* db.allAsync('SELECT * FROM pets;').then(resolve),
|
|
161
158
|
* ),
|
|
162
159
|
* );
|
|
163
160
|
* // -> [{_id: 'fido', species: 'dog'}]
|
|
164
161
|
*
|
|
165
162
|
* await new Promise((resolve) =>
|
|
166
|
-
* db
|
|
167
|
-
* `INSERT INTO pets (_id, species) VALUES ('felix', 'cat')
|
|
168
|
-
* resolve,
|
|
169
|
-
* ),
|
|
163
|
+
* db
|
|
164
|
+
* .allAsync(`INSERT INTO pets (_id, species) VALUES ('felix', 'cat')`)
|
|
165
|
+
* .then(resolve),
|
|
170
166
|
* );
|
|
171
167
|
* await persister.load();
|
|
172
168
|
* console.log(store.getTables());
|
|
@@ -175,7 +171,7 @@ export interface ExpoSqlitePersister extends Persister<3> {
|
|
|
175
171
|
* persister.destroy();
|
|
176
172
|
* ```
|
|
177
173
|
* @category Creation
|
|
178
|
-
* @since v4.0
|
|
174
|
+
* @since v4.5.0
|
|
179
175
|
*/
|
|
180
176
|
export function createExpoSqlitePersister(
|
|
181
177
|
store: Store | MergeableStore,
|
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The persister-expo-sqlite module of the TinyBase project lets you save and
|
|
3
|
-
* load Store data to and from a
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* This module provides a Persister for the legacy version of Expo's
|
|
7
|
-
* [SQLite](https://docs.expo.dev/versions/latest/sdk/sqlite) library. This API
|
|
8
|
-
* should be used if you are installing the `expo-sqlite` module.
|
|
3
|
+
* load Store data to and from a Expo-SQLite database (in an appropriate React
|
|
4
|
+
* Native environment).
|
|
9
5
|
*
|
|
10
|
-
*
|
|
11
|
-
* (
|
|
12
|
-
*
|
|
6
|
+
* As of TinyBase v5.0, this module provides a Persister for the modern version
|
|
7
|
+
* of Expo's [SQLite](https://docs.expo.dev/versions/latest/sdk/sqlite) library,
|
|
8
|
+
* designated 'next' as of November 2023 and default as v14.0 by June 2024.
|
|
13
9
|
*
|
|
14
|
-
* Note that
|
|
15
|
-
*
|
|
10
|
+
* Note that TinyBase support for the legacy version of Expo-SQLite is no longer
|
|
11
|
+
* available.
|
|
16
12
|
* @see Persisting Data guide
|
|
17
13
|
* @packageDocumentation
|
|
18
14
|
* @module persister-expo-sqlite
|
|
19
|
-
* @since v4.0
|
|
15
|
+
* @since v4.5.0
|
|
20
16
|
*/
|
|
21
17
|
|
|
22
18
|
import type {
|
|
@@ -40,7 +36,7 @@ import type {SQLiteDatabase} from 'expo-sqlite';
|
|
|
40
36
|
* You should use the createExpoSqlitePersister function to create an
|
|
41
37
|
* ExpoSqlitePersister object.
|
|
42
38
|
* @category Persister
|
|
43
|
-
* @since v4.
|
|
39
|
+
* @since v4.5.0
|
|
44
40
|
*/
|
|
45
41
|
export interface ExpoSqlitePersister<Schemas extends OptionalSchemas>
|
|
46
42
|
extends Persister<Schemas, 3> {
|
|
@@ -55,9 +51,9 @@ export interface ExpoSqlitePersister<Schemas extends OptionalSchemas>
|
|
|
55
51
|
* ```js yolo
|
|
56
52
|
* import {createExpoSqlitePersister} from 'tinybase/persisters/persister-expo-sqlite';
|
|
57
53
|
* import {createStore} from 'tinybase';
|
|
58
|
-
* import {
|
|
54
|
+
* import {openDatabaseSync} from 'expo-sqlite';
|
|
59
55
|
*
|
|
60
|
-
* const db =
|
|
56
|
+
* const db = openDatabaseSync('my.db');
|
|
61
57
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
62
58
|
* const persister = createExpoSqlitePersister(store, db, 'my_tinybase');
|
|
63
59
|
*
|
|
@@ -67,7 +63,7 @@ export interface ExpoSqlitePersister<Schemas extends OptionalSchemas>
|
|
|
67
63
|
* persister.destroy();
|
|
68
64
|
* ```
|
|
69
65
|
* @category Getter
|
|
70
|
-
* @since v4.
|
|
66
|
+
* @since v4.5.0
|
|
71
67
|
*/
|
|
72
68
|
getDb(): SQLiteDatabase;
|
|
73
69
|
}
|
|
@@ -114,23 +110,23 @@ export interface ExpoSqlitePersister<Schemas extends OptionalSchemas>
|
|
|
114
110
|
* JSON serialization).
|
|
115
111
|
* @param onSqlCommand An optional handler called every time the Persister
|
|
116
112
|
* executes a SQL command or query. This is suitable for logging persistence
|
|
117
|
-
* behavior in a development environment
|
|
113
|
+
* behavior in a development environment.
|
|
118
114
|
* @param onIgnoredError An optional handler for the errors that the Persister
|
|
119
115
|
* would otherwise ignore when trying to save or load data. This is suitable for
|
|
120
|
-
* debugging persistence issues in a development environment
|
|
116
|
+
* debugging persistence issues in a development environment.
|
|
121
117
|
* @returns A reference to the new ExpoSqlitePersister object.
|
|
122
118
|
* @example
|
|
123
|
-
* This example creates a ExpoSqlitePersister object and persists the Store
|
|
124
|
-
* local SQLite database as a JSON serialization into the `my_tinybase`
|
|
125
|
-
* It makes a change to the database directly and then reloads it back
|
|
126
|
-
* Store.
|
|
119
|
+
* This example creates a ExpoSqlitePersister object and persists the Store
|
|
120
|
+
* to a local SQLite database as a JSON serialization into the `my_tinybase`
|
|
121
|
+
* table. It makes a change to the database directly and then reloads it back
|
|
122
|
+
* into the Store.
|
|
127
123
|
*
|
|
128
124
|
* ```js yolo
|
|
129
125
|
* import {createExpoSqlitePersister} from 'tinybase/persisters/persister-expo-sqlite';
|
|
130
126
|
* import {createStore} from 'tinybase';
|
|
131
|
-
* import {
|
|
127
|
+
* import {openDatabaseSync} from 'expo-sqlite';
|
|
132
128
|
*
|
|
133
|
-
* const db =
|
|
129
|
+
* const db = openDatabaseSync('my.db');
|
|
134
130
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
135
131
|
* const persister = createExpoSqlitePersister(store, db, 'my_tinybase');
|
|
136
132
|
*
|
|
@@ -139,17 +135,18 @@ export interface ExpoSqlitePersister<Schemas extends OptionalSchemas>
|
|
|
139
135
|
*
|
|
140
136
|
* console.log(
|
|
141
137
|
* await new Promise((resolve) =>
|
|
142
|
-
* db.
|
|
138
|
+
* db.allAsync('SELECT * FROM my_tinybase;').then(resolve),
|
|
143
139
|
* ),
|
|
144
140
|
* );
|
|
145
141
|
* // -> [{_id: '_', store: '[{"pets":{"fido":{"species":"dog"}}},{}]'}]
|
|
146
142
|
*
|
|
147
143
|
* await new Promise((resolve) =>
|
|
148
|
-
* db
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
144
|
+
* db
|
|
145
|
+
* .allAsync(
|
|
146
|
+
* 'UPDATE my_tinybase SET store = ' +
|
|
147
|
+
* `'[{"pets":{"felix":{"species":"cat"}}},{}]' WHERE _id = '_';`,
|
|
148
|
+
* )
|
|
149
|
+
* .then(resolve),
|
|
153
150
|
* );
|
|
154
151
|
* await persister.load();
|
|
155
152
|
* console.log(store.getTables());
|
|
@@ -158,15 +155,15 @@ export interface ExpoSqlitePersister<Schemas extends OptionalSchemas>
|
|
|
158
155
|
* persister.destroy();
|
|
159
156
|
* ```
|
|
160
157
|
* @example
|
|
161
|
-
* This example creates a ExpoSqlitePersister object and persists the Store
|
|
162
|
-
* local SQLite database with tabular mapping.
|
|
158
|
+
* This example creates a ExpoSqlitePersister object and persists the Store
|
|
159
|
+
* to a local SQLite database with tabular mapping.
|
|
163
160
|
*
|
|
164
161
|
* ```js yolo
|
|
165
162
|
* import {createExpoSqlitePersister} from 'tinybase/persisters/persister-expo-sqlite';
|
|
166
163
|
* import {createStore} from 'tinybase';
|
|
167
|
-
* import {
|
|
164
|
+
* import {openDatabaseSync} from 'expo-sqlite';
|
|
168
165
|
*
|
|
169
|
-
* const db =
|
|
166
|
+
* const db = openDatabaseSync('my.db');
|
|
170
167
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
171
168
|
* const persister = createExpoSqlitePersister(store, db, {
|
|
172
169
|
* mode: 'tabular',
|
|
@@ -176,16 +173,15 @@ export interface ExpoSqlitePersister<Schemas extends OptionalSchemas>
|
|
|
176
173
|
* await persister.save();
|
|
177
174
|
* console.log(
|
|
178
175
|
* await new Promise((resolve) =>
|
|
179
|
-
* db.
|
|
176
|
+
* db.allAsync('SELECT * FROM pets;').then(resolve),
|
|
180
177
|
* ),
|
|
181
178
|
* );
|
|
182
179
|
* // -> [{_id: 'fido', species: 'dog'}]
|
|
183
180
|
*
|
|
184
181
|
* await new Promise((resolve) =>
|
|
185
|
-
* db
|
|
186
|
-
* `INSERT INTO pets (_id, species) VALUES ('felix', 'cat')
|
|
187
|
-
* resolve,
|
|
188
|
-
* ),
|
|
182
|
+
* db
|
|
183
|
+
* .allAsync(`INSERT INTO pets (_id, species) VALUES ('felix', 'cat')`)
|
|
184
|
+
* .then(resolve),
|
|
189
185
|
* );
|
|
190
186
|
* await persister.load();
|
|
191
187
|
* console.log(store.getTables());
|
|
@@ -194,7 +190,7 @@ export interface ExpoSqlitePersister<Schemas extends OptionalSchemas>
|
|
|
194
190
|
* persister.destroy();
|
|
195
191
|
* ```
|
|
196
192
|
* @category Creation
|
|
197
|
-
* @since v4.0
|
|
193
|
+
* @since v4.5.0
|
|
198
194
|
*/
|
|
199
195
|
export function createExpoSqlitePersister<Schemas extends OptionalSchemas>(
|
|
200
196
|
store: Store<Schemas> | MergeableStore<Schemas>,
|
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The persister-expo-sqlite module of the TinyBase project lets you save and
|
|
3
|
-
* load Store data to and from a
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* This module provides a Persister for the legacy version of Expo's
|
|
7
|
-
* [SQLite](https://docs.expo.dev/versions/latest/sdk/sqlite) library. This API
|
|
8
|
-
* should be used if you are installing the `expo-sqlite` module.
|
|
3
|
+
* load Store data to and from a Expo-SQLite database (in an appropriate React
|
|
4
|
+
* Native environment).
|
|
9
5
|
*
|
|
10
|
-
*
|
|
11
|
-
* (
|
|
12
|
-
*
|
|
6
|
+
* As of TinyBase v5.0, this module provides a Persister for the modern version
|
|
7
|
+
* of Expo's [SQLite](https://docs.expo.dev/versions/latest/sdk/sqlite) library,
|
|
8
|
+
* designated 'next' as of November 2023 and default as v14.0 by June 2024.
|
|
13
9
|
*
|
|
14
|
-
* Note that
|
|
15
|
-
*
|
|
10
|
+
* Note that TinyBase support for the legacy version of Expo-SQLite is no longer
|
|
11
|
+
* available.
|
|
16
12
|
* @see Persisting Data guide
|
|
17
13
|
* @packageDocumentation
|
|
18
14
|
* @module persister-expo-sqlite
|
|
19
|
-
* @since v4.0
|
|
15
|
+
* @since v4.5.0
|
|
20
16
|
*/
|
|
21
17
|
|
|
22
18
|
import type {
|
|
@@ -40,7 +36,7 @@ import type {SQLiteDatabase} from 'expo-sqlite';
|
|
|
40
36
|
* You should use the createExpoSqlitePersister function to create an
|
|
41
37
|
* ExpoSqlitePersister object.
|
|
42
38
|
* @category Persister
|
|
43
|
-
* @since v4.
|
|
39
|
+
* @since v4.5.0
|
|
44
40
|
*/
|
|
45
41
|
export interface ExpoSqlitePersister<Schemas extends OptionalSchemas>
|
|
46
42
|
extends Persister<Schemas, 3> {
|
|
@@ -55,9 +51,9 @@ export interface ExpoSqlitePersister<Schemas extends OptionalSchemas>
|
|
|
55
51
|
* ```js yolo
|
|
56
52
|
* import {createExpoSqlitePersister} from 'tinybase/persisters/persister-expo-sqlite';
|
|
57
53
|
* import {createStore} from 'tinybase';
|
|
58
|
-
* import {
|
|
54
|
+
* import {openDatabaseSync} from 'expo-sqlite';
|
|
59
55
|
*
|
|
60
|
-
* const db =
|
|
56
|
+
* const db = openDatabaseSync('my.db');
|
|
61
57
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
62
58
|
* const persister = createExpoSqlitePersister(store, db, 'my_tinybase');
|
|
63
59
|
*
|
|
@@ -67,7 +63,7 @@ export interface ExpoSqlitePersister<Schemas extends OptionalSchemas>
|
|
|
67
63
|
* persister.destroy();
|
|
68
64
|
* ```
|
|
69
65
|
* @category Getter
|
|
70
|
-
* @since v4.
|
|
66
|
+
* @since v4.5.0
|
|
71
67
|
*/
|
|
72
68
|
getDb(): SQLiteDatabase;
|
|
73
69
|
}
|
|
@@ -114,23 +110,23 @@ export interface ExpoSqlitePersister<Schemas extends OptionalSchemas>
|
|
|
114
110
|
* JSON serialization).
|
|
115
111
|
* @param onSqlCommand An optional handler called every time the Persister
|
|
116
112
|
* executes a SQL command or query. This is suitable for logging persistence
|
|
117
|
-
* behavior in a development environment
|
|
113
|
+
* behavior in a development environment.
|
|
118
114
|
* @param onIgnoredError An optional handler for the errors that the Persister
|
|
119
115
|
* would otherwise ignore when trying to save or load data. This is suitable for
|
|
120
|
-
* debugging persistence issues in a development environment
|
|
116
|
+
* debugging persistence issues in a development environment.
|
|
121
117
|
* @returns A reference to the new ExpoSqlitePersister object.
|
|
122
118
|
* @example
|
|
123
|
-
* This example creates a ExpoSqlitePersister object and persists the Store
|
|
124
|
-
* local SQLite database as a JSON serialization into the `my_tinybase`
|
|
125
|
-
* It makes a change to the database directly and then reloads it back
|
|
126
|
-
* Store.
|
|
119
|
+
* This example creates a ExpoSqlitePersister object and persists the Store
|
|
120
|
+
* to a local SQLite database as a JSON serialization into the `my_tinybase`
|
|
121
|
+
* table. It makes a change to the database directly and then reloads it back
|
|
122
|
+
* into the Store.
|
|
127
123
|
*
|
|
128
124
|
* ```js yolo
|
|
129
125
|
* import {createExpoSqlitePersister} from 'tinybase/persisters/persister-expo-sqlite';
|
|
130
126
|
* import {createStore} from 'tinybase';
|
|
131
|
-
* import {
|
|
127
|
+
* import {openDatabaseSync} from 'expo-sqlite';
|
|
132
128
|
*
|
|
133
|
-
* const db =
|
|
129
|
+
* const db = openDatabaseSync('my.db');
|
|
134
130
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
135
131
|
* const persister = createExpoSqlitePersister(store, db, 'my_tinybase');
|
|
136
132
|
*
|
|
@@ -139,17 +135,18 @@ export interface ExpoSqlitePersister<Schemas extends OptionalSchemas>
|
|
|
139
135
|
*
|
|
140
136
|
* console.log(
|
|
141
137
|
* await new Promise((resolve) =>
|
|
142
|
-
* db.
|
|
138
|
+
* db.allAsync('SELECT * FROM my_tinybase;').then(resolve),
|
|
143
139
|
* ),
|
|
144
140
|
* );
|
|
145
141
|
* // -> [{_id: '_', store: '[{"pets":{"fido":{"species":"dog"}}},{}]'}]
|
|
146
142
|
*
|
|
147
143
|
* await new Promise((resolve) =>
|
|
148
|
-
* db
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
144
|
+
* db
|
|
145
|
+
* .allAsync(
|
|
146
|
+
* 'UPDATE my_tinybase SET store = ' +
|
|
147
|
+
* `'[{"pets":{"felix":{"species":"cat"}}},{}]' WHERE _id = '_';`,
|
|
148
|
+
* )
|
|
149
|
+
* .then(resolve),
|
|
153
150
|
* );
|
|
154
151
|
* await persister.load();
|
|
155
152
|
* console.log(store.getTables());
|
|
@@ -158,15 +155,15 @@ export interface ExpoSqlitePersister<Schemas extends OptionalSchemas>
|
|
|
158
155
|
* persister.destroy();
|
|
159
156
|
* ```
|
|
160
157
|
* @example
|
|
161
|
-
* This example creates a ExpoSqlitePersister object and persists the Store
|
|
162
|
-
* local SQLite database with tabular mapping.
|
|
158
|
+
* This example creates a ExpoSqlitePersister object and persists the Store
|
|
159
|
+
* to a local SQLite database with tabular mapping.
|
|
163
160
|
*
|
|
164
161
|
* ```js yolo
|
|
165
162
|
* import {createExpoSqlitePersister} from 'tinybase/persisters/persister-expo-sqlite';
|
|
166
163
|
* import {createStore} from 'tinybase';
|
|
167
|
-
* import {
|
|
164
|
+
* import {openDatabaseSync} from 'expo-sqlite';
|
|
168
165
|
*
|
|
169
|
-
* const db =
|
|
166
|
+
* const db = openDatabaseSync('my.db');
|
|
170
167
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
171
168
|
* const persister = createExpoSqlitePersister(store, db, {
|
|
172
169
|
* mode: 'tabular',
|
|
@@ -176,16 +173,15 @@ export interface ExpoSqlitePersister<Schemas extends OptionalSchemas>
|
|
|
176
173
|
* await persister.save();
|
|
177
174
|
* console.log(
|
|
178
175
|
* await new Promise((resolve) =>
|
|
179
|
-
* db.
|
|
176
|
+
* db.allAsync('SELECT * FROM pets;').then(resolve),
|
|
180
177
|
* ),
|
|
181
178
|
* );
|
|
182
179
|
* // -> [{_id: 'fido', species: 'dog'}]
|
|
183
180
|
*
|
|
184
181
|
* await new Promise((resolve) =>
|
|
185
|
-
* db
|
|
186
|
-
* `INSERT INTO pets (_id, species) VALUES ('felix', 'cat')
|
|
187
|
-
* resolve,
|
|
188
|
-
* ),
|
|
182
|
+
* db
|
|
183
|
+
* .allAsync(`INSERT INTO pets (_id, species) VALUES ('felix', 'cat')`)
|
|
184
|
+
* .then(resolve),
|
|
189
185
|
* );
|
|
190
186
|
* await persister.load();
|
|
191
187
|
* console.log(store.getTables());
|
|
@@ -194,7 +190,7 @@ export interface ExpoSqlitePersister<Schemas extends OptionalSchemas>
|
|
|
194
190
|
* persister.destroy();
|
|
195
191
|
* ```
|
|
196
192
|
* @category Creation
|
|
197
|
-
* @since v4.0
|
|
193
|
+
* @since v4.5.0
|
|
198
194
|
*/
|
|
199
195
|
export function createExpoSqlitePersister<Schemas extends OptionalSchemas>(
|
|
200
196
|
store: Store<Schemas> | MergeableStore<Schemas>,
|