tinybase 5.0.0-beta.22 → 5.0.0-beta.23
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 +3 -107
- 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 +1 -1
- 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 +9 -6
- package/umd/es6/persisters/persister-expo-sqlite/with-schemas/index.js +9 -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 +9 -7
- package/umd/persisters/persister-expo-sqlite/with-schemas/index.js +9 -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,187 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The persister-expo-sqlite-next module of the TinyBase project lets you save
|
|
3
|
-
* and load Store data to and from a local Expo-SQLite 'next' database (in an
|
|
4
|
-
* appropriate React Native environment).
|
|
5
|
-
*
|
|
6
|
-
* This module provides a Persister for the modern version of Expo's
|
|
7
|
-
* [SQLite](https://docs.expo.dev/versions/latest/sdk/sqlite)
|
|
8
|
-
* library, designated 'next' as of November 2023. This API should be used if
|
|
9
|
-
* you are installing the `expo-sqlite/next` module. In the future we expect
|
|
10
|
-
* this module to become the default.
|
|
11
|
-
*
|
|
12
|
-
* Note that TinyBase support for the legacy version of Expo-SQLite
|
|
13
|
-
* (`expo-sqlite`) is still available in the persister-expo-sqlite module.
|
|
14
|
-
*
|
|
15
|
-
* Note that this Persister is currently experimental as Expo themselves iterate
|
|
16
|
-
* on the underlying database library API.
|
|
17
|
-
* @see Persisting Data guide
|
|
18
|
-
* @packageDocumentation
|
|
19
|
-
* @module persister-expo-sqlite-next
|
|
20
|
-
* @since v4.5.0
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
import type {DatabasePersisterConfig, Persister} from '../index.d.cts';
|
|
24
|
-
import type {MergeableStore} from '../../mergeable-store/index.d.cts';
|
|
25
|
-
import type {SQLiteDatabase} from 'expo-sqlite/next.d.cts';
|
|
26
|
-
import type {Store} from '../../store/index.d.cts';
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* The ExpoSqliteNextPersister interface is a minor extension to the Persister
|
|
30
|
-
* interface.
|
|
31
|
-
*
|
|
32
|
-
* It simply provides an extra getDb method for accessing a reference to the
|
|
33
|
-
* database instance the Store is being persisted to.
|
|
34
|
-
*
|
|
35
|
-
* You should use the createExpoSqliteNextPersister function to create an
|
|
36
|
-
* ExpoSqliteNextPersister object.
|
|
37
|
-
* @category Persister
|
|
38
|
-
* @since v4.5.0
|
|
39
|
-
*/
|
|
40
|
-
export interface ExpoSqliteNextPersister extends Persister<3> {
|
|
41
|
-
/**
|
|
42
|
-
* The getDb method returns a reference to the database instance the Store is
|
|
43
|
-
* being persisted to.
|
|
44
|
-
* @returns A reference to the database instance.
|
|
45
|
-
* @example
|
|
46
|
-
* This example creates a Persister object against a newly-created Store and
|
|
47
|
-
* then gets the database instance back out again.
|
|
48
|
-
*
|
|
49
|
-
* ```js yolo
|
|
50
|
-
* import {createExpoSqliteNextPersister} from 'tinybase/persisters/persister-expo-sqlite-next';
|
|
51
|
-
* import {createStore} from 'tinybase';
|
|
52
|
-
* import {openDatabaseSync} from 'expo-sqlite';
|
|
53
|
-
*
|
|
54
|
-
* const db = openDatabaseSync('my.db');
|
|
55
|
-
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
56
|
-
* const persister = createExpoSqliteNextPersister(store, db, 'my_tinybase');
|
|
57
|
-
*
|
|
58
|
-
* console.log(persister.getDb() == db);
|
|
59
|
-
* // -> true
|
|
60
|
-
*
|
|
61
|
-
* persister.destroy();
|
|
62
|
-
* ```
|
|
63
|
-
* @category Getter
|
|
64
|
-
* @since v4.5.0
|
|
65
|
-
*/
|
|
66
|
-
getDb(): SQLiteDatabase;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* The createExpoSqliteNextPersister function creates a Persister object that
|
|
71
|
-
* can persist the Store to a local Expo-SQLite database (in an appropriate
|
|
72
|
-
* React Native environment).
|
|
73
|
-
*
|
|
74
|
-
* Note that this Persister is currently experimental as Expo themselves iterate
|
|
75
|
-
* on the underlying database library API.
|
|
76
|
-
*
|
|
77
|
-
* As well as providing a reference to the Store to persist, you must provide a
|
|
78
|
-
* `db` parameter which identifies the database instance.
|
|
79
|
-
*
|
|
80
|
-
* A database Persister uses one of two modes: either a JSON serialization of
|
|
81
|
-
* the whole Store stored in a single row of a table (the default), or a tabular
|
|
82
|
-
* mapping of Table Ids to database table names and vice-versa).
|
|
83
|
-
*
|
|
84
|
-
* The third argument is a DatabasePersisterConfig object that configures which
|
|
85
|
-
* of those modes to use, and settings for each. If the third argument is simply
|
|
86
|
-
* a string, it is used as the `storeTableName` property of the JSON
|
|
87
|
-
* serialization.
|
|
88
|
-
*
|
|
89
|
-
* See the documentation for the DpcJson and DpcTabular types for more
|
|
90
|
-
* information on how both of those modes can be configured.
|
|
91
|
-
* @param store The Store to persist.
|
|
92
|
-
* @param db The database instance that was returned from
|
|
93
|
-
* `SQLite.openDatabase(...)`.
|
|
94
|
-
* @param configOrStoreTableName A DatabasePersisterConfig to configure the
|
|
95
|
-
* persistence mode (or a string to set the `storeTableName` property of the
|
|
96
|
-
* JSON serialization).
|
|
97
|
-
* @param onSqlCommand An optional handler called every time the Persister
|
|
98
|
-
* executes a SQL command or query. This is suitable for logging persistence
|
|
99
|
-
* behavior in a development environment.
|
|
100
|
-
* @param onIgnoredError An optional handler for the errors that the Persister
|
|
101
|
-
* would otherwise ignore when trying to save or load data. This is suitable for
|
|
102
|
-
* debugging persistence issues in a development environment.
|
|
103
|
-
* @returns A reference to the new ExpoSqliteNextPersister object.
|
|
104
|
-
* @example
|
|
105
|
-
* This example creates a ExpoSqliteNextPersister object and persists the Store
|
|
106
|
-
* to a local SQLite database as a JSON serialization into the `my_tinybase`
|
|
107
|
-
* table. It makes a change to the database directly and then reloads it back
|
|
108
|
-
* into the Store.
|
|
109
|
-
*
|
|
110
|
-
* ```js yolo
|
|
111
|
-
* import {createExpoSqliteNextPersister} from 'tinybase/persisters/persister-expo-sqlite-next';
|
|
112
|
-
* import {createStore} from 'tinybase';
|
|
113
|
-
* import {openDatabaseSync} from 'expo-sqlite';
|
|
114
|
-
*
|
|
115
|
-
* const db = openDatabaseSync('my.db');
|
|
116
|
-
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
117
|
-
* const persister = createExpoSqliteNextPersister(store, db, 'my_tinybase');
|
|
118
|
-
*
|
|
119
|
-
* await persister.save();
|
|
120
|
-
* // Store will be saved to the database.
|
|
121
|
-
*
|
|
122
|
-
* console.log(
|
|
123
|
-
* await new Promise((resolve) =>
|
|
124
|
-
* db.allAsync('SELECT * FROM my_tinybase;').then(resolve),
|
|
125
|
-
* ),
|
|
126
|
-
* );
|
|
127
|
-
* // -> [{_id: '_', store: '[{"pets":{"fido":{"species":"dog"}}},{}]'}]
|
|
128
|
-
*
|
|
129
|
-
* await new Promise((resolve) =>
|
|
130
|
-
* db
|
|
131
|
-
* .allAsync(
|
|
132
|
-
* 'UPDATE my_tinybase SET store = ' +
|
|
133
|
-
* `'[{"pets":{"felix":{"species":"cat"}}},{}]' WHERE _id = '_';`,
|
|
134
|
-
* )
|
|
135
|
-
* .then(resolve),
|
|
136
|
-
* );
|
|
137
|
-
* await persister.load();
|
|
138
|
-
* console.log(store.getTables());
|
|
139
|
-
* // -> {pets: {felix: {species: 'cat'}}}
|
|
140
|
-
*
|
|
141
|
-
* persister.destroy();
|
|
142
|
-
* ```
|
|
143
|
-
* @example
|
|
144
|
-
* This example creates a ExpoSqliteNextPersister object and persists the Store
|
|
145
|
-
* to a local SQLite database with tabular mapping.
|
|
146
|
-
*
|
|
147
|
-
* ```js yolo
|
|
148
|
-
* import {createExpoSqliteNextPersister} from 'tinybase/persisters/persister-expo-sqlite-next';
|
|
149
|
-
* import {createStore} from 'tinybase';
|
|
150
|
-
* import {openDatabaseSync} from 'expo-sqlite';
|
|
151
|
-
*
|
|
152
|
-
* const db = openDatabaseSync('my.db');
|
|
153
|
-
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
154
|
-
* const persister = createExpoSqliteNextPersister(store, db, {
|
|
155
|
-
* mode: 'tabular',
|
|
156
|
-
* tables: {load: {pets: 'pets'}, save: {pets: 'pets'}},
|
|
157
|
-
* });
|
|
158
|
-
*
|
|
159
|
-
* await persister.save();
|
|
160
|
-
* console.log(
|
|
161
|
-
* await new Promise((resolve) =>
|
|
162
|
-
* db.allAsync('SELECT * FROM pets;').then(resolve),
|
|
163
|
-
* ),
|
|
164
|
-
* );
|
|
165
|
-
* // -> [{_id: 'fido', species: 'dog'}]
|
|
166
|
-
*
|
|
167
|
-
* await new Promise((resolve) =>
|
|
168
|
-
* db
|
|
169
|
-
* .allAsync(`INSERT INTO pets (_id, species) VALUES ('felix', 'cat')`)
|
|
170
|
-
* .then(resolve),
|
|
171
|
-
* );
|
|
172
|
-
* await persister.load();
|
|
173
|
-
* console.log(store.getTables());
|
|
174
|
-
* // -> {pets: {fido: {species: 'dog'}, felix: {species: 'cat'}}}
|
|
175
|
-
*
|
|
176
|
-
* persister.destroy();
|
|
177
|
-
* ```
|
|
178
|
-
* @category Creation
|
|
179
|
-
* @since v4.5.0
|
|
180
|
-
*/
|
|
181
|
-
export function createExpoSqliteNextPersister(
|
|
182
|
-
store: Store | MergeableStore,
|
|
183
|
-
db: SQLiteDatabase,
|
|
184
|
-
configOrStoreTableName?: DatabasePersisterConfig | string,
|
|
185
|
-
onSqlCommand?: (sql: string, args?: any[]) => void,
|
|
186
|
-
onIgnoredError?: (error: any) => void,
|
|
187
|
-
): ExpoSqliteNextPersister;
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The persister-expo-sqlite-next module of the TinyBase project lets you save
|
|
3
|
-
* and load Store data to and from a local Expo-SQLite 'next' database (in an
|
|
4
|
-
* appropriate React Native environment).
|
|
5
|
-
*
|
|
6
|
-
* This module provides a Persister for the modern version of Expo's
|
|
7
|
-
* [SQLite](https://docs.expo.dev/versions/latest/sdk/sqlite)
|
|
8
|
-
* library, designated 'next' as of November 2023. This API should be used if
|
|
9
|
-
* you are installing the `expo-sqlite/next` module. In the future we expect
|
|
10
|
-
* this module to become the default.
|
|
11
|
-
*
|
|
12
|
-
* Note that TinyBase support for the legacy version of Expo-SQLite
|
|
13
|
-
* (`expo-sqlite`) is still available in the persister-expo-sqlite module.
|
|
14
|
-
*
|
|
15
|
-
* Note that this Persister is currently experimental as Expo themselves iterate
|
|
16
|
-
* on the underlying database library API.
|
|
17
|
-
* @see Persisting Data guide
|
|
18
|
-
* @packageDocumentation
|
|
19
|
-
* @module persister-expo-sqlite-next
|
|
20
|
-
* @since v4.5.0
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
import type {DatabasePersisterConfig, Persister} from '../index.d.ts';
|
|
24
|
-
import type {MergeableStore} from '../../mergeable-store/index.d.ts';
|
|
25
|
-
import type {SQLiteDatabase} from 'expo-sqlite/next.d.ts';
|
|
26
|
-
import type {Store} from '../../store/index.d.ts';
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* The ExpoSqliteNextPersister interface is a minor extension to the Persister
|
|
30
|
-
* interface.
|
|
31
|
-
*
|
|
32
|
-
* It simply provides an extra getDb method for accessing a reference to the
|
|
33
|
-
* database instance the Store is being persisted to.
|
|
34
|
-
*
|
|
35
|
-
* You should use the createExpoSqliteNextPersister function to create an
|
|
36
|
-
* ExpoSqliteNextPersister object.
|
|
37
|
-
* @category Persister
|
|
38
|
-
* @since v4.5.0
|
|
39
|
-
*/
|
|
40
|
-
export interface ExpoSqliteNextPersister extends Persister<3> {
|
|
41
|
-
/**
|
|
42
|
-
* The getDb method returns a reference to the database instance the Store is
|
|
43
|
-
* being persisted to.
|
|
44
|
-
* @returns A reference to the database instance.
|
|
45
|
-
* @example
|
|
46
|
-
* This example creates a Persister object against a newly-created Store and
|
|
47
|
-
* then gets the database instance back out again.
|
|
48
|
-
*
|
|
49
|
-
* ```js yolo
|
|
50
|
-
* import {createExpoSqliteNextPersister} from 'tinybase/persisters/persister-expo-sqlite-next';
|
|
51
|
-
* import {createStore} from 'tinybase';
|
|
52
|
-
* import {openDatabaseSync} from 'expo-sqlite';
|
|
53
|
-
*
|
|
54
|
-
* const db = openDatabaseSync('my.db');
|
|
55
|
-
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
56
|
-
* const persister = createExpoSqliteNextPersister(store, db, 'my_tinybase');
|
|
57
|
-
*
|
|
58
|
-
* console.log(persister.getDb() == db);
|
|
59
|
-
* // -> true
|
|
60
|
-
*
|
|
61
|
-
* persister.destroy();
|
|
62
|
-
* ```
|
|
63
|
-
* @category Getter
|
|
64
|
-
* @since v4.5.0
|
|
65
|
-
*/
|
|
66
|
-
getDb(): SQLiteDatabase;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* The createExpoSqliteNextPersister function creates a Persister object that
|
|
71
|
-
* can persist the Store to a local Expo-SQLite database (in an appropriate
|
|
72
|
-
* React Native environment).
|
|
73
|
-
*
|
|
74
|
-
* Note that this Persister is currently experimental as Expo themselves iterate
|
|
75
|
-
* on the underlying database library API.
|
|
76
|
-
*
|
|
77
|
-
* As well as providing a reference to the Store to persist, you must provide a
|
|
78
|
-
* `db` parameter which identifies the database instance.
|
|
79
|
-
*
|
|
80
|
-
* A database Persister uses one of two modes: either a JSON serialization of
|
|
81
|
-
* the whole Store stored in a single row of a table (the default), or a tabular
|
|
82
|
-
* mapping of Table Ids to database table names and vice-versa).
|
|
83
|
-
*
|
|
84
|
-
* The third argument is a DatabasePersisterConfig object that configures which
|
|
85
|
-
* of those modes to use, and settings for each. If the third argument is simply
|
|
86
|
-
* a string, it is used as the `storeTableName` property of the JSON
|
|
87
|
-
* serialization.
|
|
88
|
-
*
|
|
89
|
-
* See the documentation for the DpcJson and DpcTabular types for more
|
|
90
|
-
* information on how both of those modes can be configured.
|
|
91
|
-
* @param store The Store to persist.
|
|
92
|
-
* @param db The database instance that was returned from
|
|
93
|
-
* `SQLite.openDatabase(...)`.
|
|
94
|
-
* @param configOrStoreTableName A DatabasePersisterConfig to configure the
|
|
95
|
-
* persistence mode (or a string to set the `storeTableName` property of the
|
|
96
|
-
* JSON serialization).
|
|
97
|
-
* @param onSqlCommand An optional handler called every time the Persister
|
|
98
|
-
* executes a SQL command or query. This is suitable for logging persistence
|
|
99
|
-
* behavior in a development environment.
|
|
100
|
-
* @param onIgnoredError An optional handler for the errors that the Persister
|
|
101
|
-
* would otherwise ignore when trying to save or load data. This is suitable for
|
|
102
|
-
* debugging persistence issues in a development environment.
|
|
103
|
-
* @returns A reference to the new ExpoSqliteNextPersister object.
|
|
104
|
-
* @example
|
|
105
|
-
* This example creates a ExpoSqliteNextPersister object and persists the Store
|
|
106
|
-
* to a local SQLite database as a JSON serialization into the `my_tinybase`
|
|
107
|
-
* table. It makes a change to the database directly and then reloads it back
|
|
108
|
-
* into the Store.
|
|
109
|
-
*
|
|
110
|
-
* ```js yolo
|
|
111
|
-
* import {createExpoSqliteNextPersister} from 'tinybase/persisters/persister-expo-sqlite-next';
|
|
112
|
-
* import {createStore} from 'tinybase';
|
|
113
|
-
* import {openDatabaseSync} from 'expo-sqlite';
|
|
114
|
-
*
|
|
115
|
-
* const db = openDatabaseSync('my.db');
|
|
116
|
-
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
117
|
-
* const persister = createExpoSqliteNextPersister(store, db, 'my_tinybase');
|
|
118
|
-
*
|
|
119
|
-
* await persister.save();
|
|
120
|
-
* // Store will be saved to the database.
|
|
121
|
-
*
|
|
122
|
-
* console.log(
|
|
123
|
-
* await new Promise((resolve) =>
|
|
124
|
-
* db.allAsync('SELECT * FROM my_tinybase;').then(resolve),
|
|
125
|
-
* ),
|
|
126
|
-
* );
|
|
127
|
-
* // -> [{_id: '_', store: '[{"pets":{"fido":{"species":"dog"}}},{}]'}]
|
|
128
|
-
*
|
|
129
|
-
* await new Promise((resolve) =>
|
|
130
|
-
* db
|
|
131
|
-
* .allAsync(
|
|
132
|
-
* 'UPDATE my_tinybase SET store = ' +
|
|
133
|
-
* `'[{"pets":{"felix":{"species":"cat"}}},{}]' WHERE _id = '_';`,
|
|
134
|
-
* )
|
|
135
|
-
* .then(resolve),
|
|
136
|
-
* );
|
|
137
|
-
* await persister.load();
|
|
138
|
-
* console.log(store.getTables());
|
|
139
|
-
* // -> {pets: {felix: {species: 'cat'}}}
|
|
140
|
-
*
|
|
141
|
-
* persister.destroy();
|
|
142
|
-
* ```
|
|
143
|
-
* @example
|
|
144
|
-
* This example creates a ExpoSqliteNextPersister object and persists the Store
|
|
145
|
-
* to a local SQLite database with tabular mapping.
|
|
146
|
-
*
|
|
147
|
-
* ```js yolo
|
|
148
|
-
* import {createExpoSqliteNextPersister} from 'tinybase/persisters/persister-expo-sqlite-next';
|
|
149
|
-
* import {createStore} from 'tinybase';
|
|
150
|
-
* import {openDatabaseSync} from 'expo-sqlite';
|
|
151
|
-
*
|
|
152
|
-
* const db = openDatabaseSync('my.db');
|
|
153
|
-
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
154
|
-
* const persister = createExpoSqliteNextPersister(store, db, {
|
|
155
|
-
* mode: 'tabular',
|
|
156
|
-
* tables: {load: {pets: 'pets'}, save: {pets: 'pets'}},
|
|
157
|
-
* });
|
|
158
|
-
*
|
|
159
|
-
* await persister.save();
|
|
160
|
-
* console.log(
|
|
161
|
-
* await new Promise((resolve) =>
|
|
162
|
-
* db.allAsync('SELECT * FROM pets;').then(resolve),
|
|
163
|
-
* ),
|
|
164
|
-
* );
|
|
165
|
-
* // -> [{_id: 'fido', species: 'dog'}]
|
|
166
|
-
*
|
|
167
|
-
* await new Promise((resolve) =>
|
|
168
|
-
* db
|
|
169
|
-
* .allAsync(`INSERT INTO pets (_id, species) VALUES ('felix', 'cat')`)
|
|
170
|
-
* .then(resolve),
|
|
171
|
-
* );
|
|
172
|
-
* await persister.load();
|
|
173
|
-
* console.log(store.getTables());
|
|
174
|
-
* // -> {pets: {fido: {species: 'dog'}, felix: {species: 'cat'}}}
|
|
175
|
-
*
|
|
176
|
-
* persister.destroy();
|
|
177
|
-
* ```
|
|
178
|
-
* @category Creation
|
|
179
|
-
* @since v4.5.0
|
|
180
|
-
*/
|
|
181
|
-
export function createExpoSqliteNextPersister(
|
|
182
|
-
store: Store | MergeableStore,
|
|
183
|
-
db: SQLiteDatabase,
|
|
184
|
-
configOrStoreTableName?: DatabasePersisterConfig | string,
|
|
185
|
-
onSqlCommand?: (sql: string, args?: any[]) => void,
|
|
186
|
-
onIgnoredError?: (error: any) => void,
|
|
187
|
-
): ExpoSqliteNextPersister;
|
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The persister-expo-sqlite-next module of the TinyBase project lets you save
|
|
3
|
-
* and load Store data to and from a local Expo-SQLite 'next' database (in an
|
|
4
|
-
* appropriate React Native environment).
|
|
5
|
-
*
|
|
6
|
-
* This module provides a Persister for the modern version of Expo's
|
|
7
|
-
* [SQLite](https://docs.expo.dev/versions/latest/sdk/sqlite)
|
|
8
|
-
* library, designated 'next' as of November 2023. This API should be used if
|
|
9
|
-
* you are installing the `expo-sqlite/next` module. In the future we expect
|
|
10
|
-
* this module to become the default.
|
|
11
|
-
*
|
|
12
|
-
* Note that TinyBase support for the legacy version of Expo-SQLite
|
|
13
|
-
* (`expo-sqlite`) is still available in the persister-expo-sqlite module.
|
|
14
|
-
*
|
|
15
|
-
* Note that this Persister is currently experimental as Expo themselves iterate
|
|
16
|
-
* on the underlying database library API.
|
|
17
|
-
* @see Persisting Data guide
|
|
18
|
-
* @packageDocumentation
|
|
19
|
-
* @module persister-expo-sqlite-next
|
|
20
|
-
* @since v4.5.0
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
import type {
|
|
24
|
-
DatabasePersisterConfig,
|
|
25
|
-
Persister,
|
|
26
|
-
} from '../../with-schemas/index.d.cts';
|
|
27
|
-
import type {
|
|
28
|
-
OptionalSchemas,
|
|
29
|
-
Store,
|
|
30
|
-
} from '../../../store/with-schemas/index.d.cts';
|
|
31
|
-
import type {MergeableStore} from '../../../mergeable-store/with-schemas/index.d.cts';
|
|
32
|
-
import type {SQLiteDatabase} from 'expo-sqlite/next.d.cts';
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* The ExpoSqliteNextPersister interface is a minor extension to the Persister
|
|
36
|
-
* interface.
|
|
37
|
-
*
|
|
38
|
-
* It simply provides an extra getDb method for accessing a reference to the
|
|
39
|
-
* database instance the Store is being persisted to.
|
|
40
|
-
*
|
|
41
|
-
* You should use the createExpoSqliteNextPersister function to create an
|
|
42
|
-
* ExpoSqliteNextPersister object.
|
|
43
|
-
* @category Persister
|
|
44
|
-
* @since v4.5.0
|
|
45
|
-
*/
|
|
46
|
-
export interface ExpoSqliteNextPersister<Schemas extends OptionalSchemas>
|
|
47
|
-
extends Persister<Schemas, 3> {
|
|
48
|
-
/**
|
|
49
|
-
* The getDb method returns a reference to the database instance the Store is
|
|
50
|
-
* being persisted to.
|
|
51
|
-
* @returns A reference to the database instance.
|
|
52
|
-
* @example
|
|
53
|
-
* This example creates a Persister object against a newly-created Store and
|
|
54
|
-
* then gets the database instance back out again.
|
|
55
|
-
*
|
|
56
|
-
* ```js yolo
|
|
57
|
-
* import {createExpoSqliteNextPersister} from 'tinybase/persisters/persister-expo-sqlite-next';
|
|
58
|
-
* import {createStore} from 'tinybase';
|
|
59
|
-
* import {openDatabaseSync} from 'expo-sqlite';
|
|
60
|
-
*
|
|
61
|
-
* const db = openDatabaseSync('my.db');
|
|
62
|
-
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
63
|
-
* const persister = createExpoSqliteNextPersister(store, db, 'my_tinybase');
|
|
64
|
-
*
|
|
65
|
-
* console.log(persister.getDb() == db);
|
|
66
|
-
* // -> true
|
|
67
|
-
*
|
|
68
|
-
* persister.destroy();
|
|
69
|
-
* ```
|
|
70
|
-
* @category Getter
|
|
71
|
-
* @since v4.5.0
|
|
72
|
-
*/
|
|
73
|
-
getDb(): SQLiteDatabase;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* The createExpoSqliteNextPersister function creates a Persister object that
|
|
78
|
-
* can persist the Store to a local Expo-SQLite database (in an appropriate
|
|
79
|
-
* React Native environment).
|
|
80
|
-
*
|
|
81
|
-
* This has schema-based typing. The following is a simplified representation:
|
|
82
|
-
*
|
|
83
|
-
* ```ts override
|
|
84
|
-
* createExpoSqliteNextPersister(
|
|
85
|
-
* store: Store | MergeableStore,
|
|
86
|
-
* db: SQLiteDatabase,
|
|
87
|
-
* configOrStoreTableName?: DatabasePersisterConfig | string,
|
|
88
|
-
* onSqlCommand?: (sql: string, args?: any[]) => void,
|
|
89
|
-
* onIgnoredError?: (error: any) => void,
|
|
90
|
-
* ): ExpoSqliteNextPersister;
|
|
91
|
-
* ```
|
|
92
|
-
*
|
|
93
|
-
* Note that this Persister is currently experimental as Expo themselves iterate
|
|
94
|
-
* on the underlying database library API.
|
|
95
|
-
*
|
|
96
|
-
* As well as providing a reference to the Store to persist, you must provide a
|
|
97
|
-
* `db` parameter which identifies the database instance.
|
|
98
|
-
*
|
|
99
|
-
* A database Persister uses one of two modes: either a JSON serialization of
|
|
100
|
-
* the whole Store stored in a single row of a table (the default), or a tabular
|
|
101
|
-
* mapping of Table Ids to database table names and vice-versa).
|
|
102
|
-
*
|
|
103
|
-
* The third argument is a DatabasePersisterConfig object that configures which
|
|
104
|
-
* of those modes to use, and settings for each. If the third argument is simply
|
|
105
|
-
* a string, it is used as the `storeTableName` property of the JSON
|
|
106
|
-
* serialization.
|
|
107
|
-
*
|
|
108
|
-
* See the documentation for the DpcJson and DpcTabular types for more
|
|
109
|
-
* information on how both of those modes can be configured.
|
|
110
|
-
* @param store The Store to persist.
|
|
111
|
-
* @param db The database instance that was returned from
|
|
112
|
-
* `SQLite.openDatabase(...)`.
|
|
113
|
-
* @param configOrStoreTableName A DatabasePersisterConfig to configure the
|
|
114
|
-
* persistence mode (or a string to set the `storeTableName` property of the
|
|
115
|
-
* JSON serialization).
|
|
116
|
-
* @param onSqlCommand An optional handler called every time the Persister
|
|
117
|
-
* executes a SQL command or query. This is suitable for logging persistence
|
|
118
|
-
* behavior in a development environment.
|
|
119
|
-
* @param onIgnoredError An optional handler for the errors that the Persister
|
|
120
|
-
* would otherwise ignore when trying to save or load data. This is suitable for
|
|
121
|
-
* debugging persistence issues in a development environment.
|
|
122
|
-
* @returns A reference to the new ExpoSqliteNextPersister object.
|
|
123
|
-
* @example
|
|
124
|
-
* This example creates a ExpoSqliteNextPersister object and persists the Store
|
|
125
|
-
* to a local SQLite database as a JSON serialization into the `my_tinybase`
|
|
126
|
-
* table. It makes a change to the database directly and then reloads it back
|
|
127
|
-
* into the Store.
|
|
128
|
-
*
|
|
129
|
-
* ```js yolo
|
|
130
|
-
* import {createExpoSqliteNextPersister} from 'tinybase/persisters/persister-expo-sqlite-next';
|
|
131
|
-
* import {createStore} from 'tinybase';
|
|
132
|
-
* import {openDatabaseSync} from 'expo-sqlite';
|
|
133
|
-
*
|
|
134
|
-
* const db = openDatabaseSync('my.db');
|
|
135
|
-
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
136
|
-
* const persister = createExpoSqliteNextPersister(store, db, 'my_tinybase');
|
|
137
|
-
*
|
|
138
|
-
* await persister.save();
|
|
139
|
-
* // Store will be saved to the database.
|
|
140
|
-
*
|
|
141
|
-
* console.log(
|
|
142
|
-
* await new Promise((resolve) =>
|
|
143
|
-
* db.allAsync('SELECT * FROM my_tinybase;').then(resolve),
|
|
144
|
-
* ),
|
|
145
|
-
* );
|
|
146
|
-
* // -> [{_id: '_', store: '[{"pets":{"fido":{"species":"dog"}}},{}]'}]
|
|
147
|
-
*
|
|
148
|
-
* await new Promise((resolve) =>
|
|
149
|
-
* db
|
|
150
|
-
* .allAsync(
|
|
151
|
-
* 'UPDATE my_tinybase SET store = ' +
|
|
152
|
-
* `'[{"pets":{"felix":{"species":"cat"}}},{}]' WHERE _id = '_';`,
|
|
153
|
-
* )
|
|
154
|
-
* .then(resolve),
|
|
155
|
-
* );
|
|
156
|
-
* await persister.load();
|
|
157
|
-
* console.log(store.getTables());
|
|
158
|
-
* // -> {pets: {felix: {species: 'cat'}}}
|
|
159
|
-
*
|
|
160
|
-
* persister.destroy();
|
|
161
|
-
* ```
|
|
162
|
-
* @example
|
|
163
|
-
* This example creates a ExpoSqliteNextPersister object and persists the Store
|
|
164
|
-
* to a local SQLite database with tabular mapping.
|
|
165
|
-
*
|
|
166
|
-
* ```js yolo
|
|
167
|
-
* import {createExpoSqliteNextPersister} from 'tinybase/persisters/persister-expo-sqlite-next';
|
|
168
|
-
* import {createStore} from 'tinybase';
|
|
169
|
-
* import {openDatabaseSync} from 'expo-sqlite';
|
|
170
|
-
*
|
|
171
|
-
* const db = openDatabaseSync('my.db');
|
|
172
|
-
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
173
|
-
* const persister = createExpoSqliteNextPersister(store, db, {
|
|
174
|
-
* mode: 'tabular',
|
|
175
|
-
* tables: {load: {pets: 'pets'}, save: {pets: 'pets'}},
|
|
176
|
-
* });
|
|
177
|
-
*
|
|
178
|
-
* await persister.save();
|
|
179
|
-
* console.log(
|
|
180
|
-
* await new Promise((resolve) =>
|
|
181
|
-
* db.allAsync('SELECT * FROM pets;').then(resolve),
|
|
182
|
-
* ),
|
|
183
|
-
* );
|
|
184
|
-
* // -> [{_id: 'fido', species: 'dog'}]
|
|
185
|
-
*
|
|
186
|
-
* await new Promise((resolve) =>
|
|
187
|
-
* db
|
|
188
|
-
* .allAsync(`INSERT INTO pets (_id, species) VALUES ('felix', 'cat')`)
|
|
189
|
-
* .then(resolve),
|
|
190
|
-
* );
|
|
191
|
-
* await persister.load();
|
|
192
|
-
* console.log(store.getTables());
|
|
193
|
-
* // -> {pets: {fido: {species: 'dog'}, felix: {species: 'cat'}}}
|
|
194
|
-
*
|
|
195
|
-
* persister.destroy();
|
|
196
|
-
* ```
|
|
197
|
-
* @category Creation
|
|
198
|
-
* @since v4.5.0
|
|
199
|
-
*/
|
|
200
|
-
export function createExpoSqliteNextPersister<Schemas extends OptionalSchemas>(
|
|
201
|
-
store: Store<Schemas> | MergeableStore<Schemas>,
|
|
202
|
-
db: SQLiteDatabase,
|
|
203
|
-
configOrStoreTableName?: DatabasePersisterConfig<Schemas> | string,
|
|
204
|
-
onSqlCommand?: (sql: string, args?: any[]) => void,
|
|
205
|
-
onIgnoredError?: (error: any) => void,
|
|
206
|
-
): ExpoSqliteNextPersister<Schemas>;
|