tinybase 7.0.0-beta.1 → 7.0.0-beta.3
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/common/index.d.ts +1 -1
- package/@types/mergeable-store/index.d.ts +2 -1
- package/@types/mergeable-store/with-schemas/index.d.ts +5 -3
- package/@types/omni/index.d.ts +2 -0
- package/@types/omni/with-schemas/index.d.ts +2 -0
- package/@types/persisters/index.d.ts +4 -0
- package/@types/persisters/persister-automerge/index.d.ts +4 -6
- package/@types/persisters/persister-automerge/with-schemas/index.d.ts +7 -8
- package/@types/persisters/persister-browser/index.d.ts +97 -6
- package/@types/persisters/persister-browser/with-schemas/index.d.ts +113 -6
- package/@types/persisters/persister-cr-sqlite-wasm/index.d.ts +4 -0
- package/@types/persisters/persister-cr-sqlite-wasm/with-schemas/index.d.ts +7 -2
- package/@types/persisters/persister-durable-object-sql-storage/index.d.ts +6 -2
- package/@types/persisters/persister-durable-object-sql-storage/with-schemas/index.d.ts +5 -0
- package/@types/persisters/persister-durable-object-storage/index.d.ts +1 -2
- package/@types/persisters/persister-durable-object-storage/with-schemas/index.d.ts +3 -2
- package/@types/persisters/persister-electric-sql/index.d.ts +4 -0
- package/@types/persisters/persister-electric-sql/with-schemas/index.d.ts +7 -2
- package/@types/persisters/persister-expo-sqlite/index.d.ts +5 -2
- package/@types/persisters/persister-expo-sqlite/with-schemas/index.d.ts +7 -2
- package/@types/persisters/persister-file/index.d.ts +1 -2
- package/@types/persisters/persister-file/with-schemas/index.d.ts +3 -2
- package/@types/persisters/persister-indexed-db/with-schemas/index.d.ts +3 -2
- package/@types/persisters/persister-libsql/index.d.ts +4 -0
- package/@types/persisters/persister-libsql/with-schemas/index.d.ts +7 -2
- package/@types/persisters/persister-partykit-client/with-schemas/index.d.ts +3 -2
- package/@types/persisters/persister-pglite/index.d.ts +7 -3
- package/@types/persisters/persister-pglite/with-schemas/index.d.ts +9 -3
- package/@types/persisters/persister-postgres/index.d.ts +5 -2
- package/@types/persisters/persister-postgres/with-schemas/index.d.ts +7 -2
- package/@types/persisters/persister-powersync/index.d.ts +4 -0
- package/@types/persisters/persister-powersync/with-schemas/index.d.ts +7 -2
- package/@types/persisters/persister-react-native-mmkv/index.d.ts +117 -0
- package/@types/persisters/persister-react-native-mmkv/with-schemas/index.d.ts +133 -0
- package/@types/persisters/persister-react-native-sqlite/index.d.ts +184 -0
- package/@types/persisters/persister-react-native-sqlite/with-schemas/index.d.ts +207 -0
- package/@types/persisters/persister-remote/with-schemas/index.d.ts +3 -2
- package/@types/persisters/persister-sqlite-bun/index.d.ts +5 -2
- package/@types/persisters/persister-sqlite-bun/with-schemas/index.d.ts +7 -2
- package/@types/persisters/persister-sqlite-wasm/index.d.ts +6 -2
- package/@types/persisters/persister-sqlite-wasm/with-schemas/index.d.ts +8 -2
- package/@types/persisters/persister-sqlite3/index.d.ts +5 -2
- package/@types/persisters/persister-sqlite3/with-schemas/index.d.ts +7 -2
- package/@types/persisters/persister-yjs/with-schemas/index.d.ts +3 -2
- package/@types/persisters/with-schemas/index.d.ts +4 -0
- package/@types/queries/index.d.ts +1 -1
- package/@types/queries/with-schemas/index.d.ts +4 -8
- package/@types/store/index.d.ts +34 -19
- package/@types/store/with-schemas/index.d.ts +28 -13
- package/@types/synchronizers/index.d.ts +1 -0
- package/@types/synchronizers/synchronizer-broadcast-channel/with-schemas/index.d.ts +3 -2
- package/@types/synchronizers/synchronizer-local/with-schemas/index.d.ts +3 -2
- package/@types/synchronizers/synchronizer-ws-client/index.d.ts +4 -2
- package/@types/synchronizers/synchronizer-ws-client/with-schemas/index.d.ts +1 -0
- package/@types/synchronizers/synchronizer-ws-server/index.d.ts +7 -7
- package/@types/synchronizers/synchronizer-ws-server/with-schemas/index.d.ts +7 -7
- package/@types/synchronizers/synchronizer-ws-server-durable-object/index.d.ts +1 -0
- package/@types/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.d.ts +1 -0
- package/@types/synchronizers/synchronizer-ws-server-simple/index.d.ts +1 -1
- package/@types/synchronizers/synchronizer-ws-server-simple/with-schemas/index.d.ts +1 -1
- package/@types/synchronizers/with-schemas/index.d.ts +4 -2
- package/@types/ui-react/index.d.ts +6 -1
- package/@types/ui-react/with-schemas/index.d.ts +6 -1
- package/@types/ui-react-dom/index.d.ts +153 -20
- package/@types/ui-react-dom/with-schemas/index.d.ts +72 -20
- package/@types/ui-react-inspector/index.d.ts +8 -0
- package/@types/ui-react-inspector/with-schemas/index.d.ts +27 -1925
- package/agents.md +343 -0
- package/checkpoints/index.js +11 -6
- package/checkpoints/with-schemas/index.js +11 -6
- package/common/index.js +8 -4
- package/common/with-schemas/index.js +8 -4
- package/index.js +63 -31
- package/indexes/index.js +10 -5
- package/indexes/with-schemas/index.js +10 -5
- package/mergeable-store/index.js +54 -22
- package/mergeable-store/with-schemas/index.js +54 -22
- package/metrics/index.js +10 -5
- package/metrics/with-schemas/index.js +10 -5
- package/min/checkpoints/index.js +1 -1
- package/min/checkpoints/index.js.gz +0 -0
- package/min/checkpoints/with-schemas/index.js +1 -1
- package/min/checkpoints/with-schemas/index.js.gz +0 -0
- package/min/common/index.js +1 -1
- package/min/common/index.js.gz +0 -0
- package/min/common/with-schemas/index.js +1 -1
- package/min/common/with-schemas/index.js.gz +0 -0
- package/min/index.js +1 -1
- package/min/index.js.gz +0 -0
- package/min/indexes/index.js +1 -1
- package/min/indexes/index.js.gz +0 -0
- package/min/indexes/with-schemas/index.js +1 -1
- package/min/indexes/with-schemas/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/metrics/index.js +1 -1
- package/min/metrics/index.js.gz +0 -0
- package/min/metrics/with-schemas/index.js +1 -1
- package/min/metrics/with-schemas/index.js.gz +0 -0
- package/min/omni/index.js +1 -1
- package/min/omni/index.js.gz +0 -0
- package/min/omni/with-schemas/index.js +1 -1
- package/min/omni/with-schemas/index.js.gz +0 -0
- package/min/persisters/index.js +1 -1
- package/min/persisters/index.js.gz +0 -0
- package/min/persisters/persister-automerge/index.js +1 -1
- package/min/persisters/persister-automerge/index.js.gz +0 -0
- package/min/persisters/persister-automerge/with-schemas/index.js +1 -1
- package/min/persisters/persister-automerge/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-browser/index.js +1 -1
- package/min/persisters/persister-browser/index.js.gz +0 -0
- package/min/persisters/persister-browser/with-schemas/index.js +1 -1
- package/min/persisters/persister-browser/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-cr-sqlite-wasm/index.js +1 -1
- package/min/persisters/persister-cr-sqlite-wasm/index.js.gz +0 -0
- package/min/persisters/persister-cr-sqlite-wasm/with-schemas/index.js +1 -1
- package/min/persisters/persister-cr-sqlite-wasm/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-durable-object-sql-storage/index.js +1 -1
- package/min/persisters/persister-durable-object-sql-storage/index.js.gz +0 -0
- package/min/persisters/persister-durable-object-sql-storage/with-schemas/index.js +1 -1
- package/min/persisters/persister-durable-object-sql-storage/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-durable-object-storage/index.js +1 -1
- package/min/persisters/persister-durable-object-storage/index.js.gz +0 -0
- package/min/persisters/persister-durable-object-storage/with-schemas/index.js +1 -1
- package/min/persisters/persister-durable-object-storage/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-electric-sql/index.js +1 -1
- package/min/persisters/persister-electric-sql/index.js.gz +0 -0
- package/min/persisters/persister-electric-sql/with-schemas/index.js +1 -1
- package/min/persisters/persister-electric-sql/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/persisters/persister-file/index.js +1 -1
- package/min/persisters/persister-file/index.js.gz +0 -0
- package/min/persisters/persister-file/with-schemas/index.js +1 -1
- package/min/persisters/persister-file/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-indexed-db/index.js +1 -1
- package/min/persisters/persister-indexed-db/index.js.gz +0 -0
- package/min/persisters/persister-indexed-db/with-schemas/index.js +1 -1
- package/min/persisters/persister-indexed-db/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-libsql/index.js +1 -1
- package/min/persisters/persister-libsql/index.js.gz +0 -0
- package/min/persisters/persister-libsql/with-schemas/index.js +1 -1
- package/min/persisters/persister-libsql/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-partykit-client/index.js +1 -1
- package/min/persisters/persister-partykit-client/index.js.gz +0 -0
- package/min/persisters/persister-partykit-client/with-schemas/index.js +1 -1
- package/min/persisters/persister-partykit-client/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-partykit-server/index.js +1 -1
- package/min/persisters/persister-partykit-server/index.js.gz +0 -0
- package/min/persisters/persister-partykit-server/with-schemas/index.js +1 -1
- package/min/persisters/persister-partykit-server/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-pglite/index.js +1 -1
- package/min/persisters/persister-pglite/index.js.gz +0 -0
- package/min/persisters/persister-pglite/with-schemas/index.js +1 -1
- package/min/persisters/persister-pglite/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-postgres/index.js +1 -1
- package/min/persisters/persister-postgres/index.js.gz +0 -0
- package/min/persisters/persister-postgres/with-schemas/index.js +1 -1
- package/min/persisters/persister-postgres/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-powersync/index.js +1 -1
- package/min/persisters/persister-powersync/index.js.gz +0 -0
- package/min/persisters/persister-powersync/with-schemas/index.js +1 -1
- package/min/persisters/persister-powersync/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-react-native-mmkv/index.js +1 -0
- package/min/persisters/persister-react-native-mmkv/index.js.gz +0 -0
- package/min/persisters/persister-react-native-mmkv/with-schemas/index.js +1 -0
- package/min/persisters/persister-react-native-mmkv/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-react-native-sqlite/index.js +1 -0
- package/min/persisters/persister-react-native-sqlite/index.js.gz +0 -0
- package/min/persisters/persister-react-native-sqlite/with-schemas/index.js +1 -0
- package/min/persisters/persister-react-native-sqlite/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-remote/index.js +1 -1
- package/min/persisters/persister-remote/index.js.gz +0 -0
- package/min/persisters/persister-remote/with-schemas/index.js +1 -1
- package/min/persisters/persister-remote/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-sqlite-bun/index.js +1 -1
- package/min/persisters/persister-sqlite-bun/index.js.gz +0 -0
- package/min/persisters/persister-sqlite-bun/with-schemas/index.js +1 -1
- package/min/persisters/persister-sqlite-bun/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-sqlite-wasm/index.js +1 -1
- package/min/persisters/persister-sqlite-wasm/index.js.gz +0 -0
- package/min/persisters/persister-sqlite-wasm/with-schemas/index.js +1 -1
- package/min/persisters/persister-sqlite-wasm/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-sqlite3/index.js +1 -1
- package/min/persisters/persister-sqlite3/index.js.gz +0 -0
- package/min/persisters/persister-sqlite3/with-schemas/index.js +1 -1
- package/min/persisters/persister-sqlite3/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-yjs/index.js +1 -1
- package/min/persisters/persister-yjs/index.js.gz +0 -0
- package/min/persisters/persister-yjs/with-schemas/index.js +1 -1
- package/min/persisters/persister-yjs/with-schemas/index.js.gz +0 -0
- package/min/persisters/with-schemas/index.js +1 -1
- package/min/persisters/with-schemas/index.js.gz +0 -0
- package/min/queries/index.js +1 -1
- package/min/queries/index.js.gz +0 -0
- package/min/queries/with-schemas/index.js +1 -1
- package/min/queries/with-schemas/index.js.gz +0 -0
- package/min/relationships/index.js +1 -1
- package/min/relationships/index.js.gz +0 -0
- package/min/relationships/with-schemas/index.js +1 -1
- package/min/relationships/with-schemas/index.js.gz +0 -0
- package/min/store/index.js +1 -1
- package/min/store/index.js.gz +0 -0
- package/min/store/with-schemas/index.js +1 -1
- package/min/store/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-broadcast-channel/index.js +1 -1
- package/min/synchronizers/synchronizer-broadcast-channel/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js +1 -1
- package/min/synchronizers/synchronizer-broadcast-channel/with-schemas/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/synchronizer-ws-server/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-server/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-server/with-schemas/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-server/with-schemas/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-server-durable-object/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-server-durable-object/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-server-simple/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-server-simple/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-server-simple/with-schemas/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-server-simple/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/ui-react/index.js +1 -1
- package/min/ui-react/index.js.gz +0 -0
- package/min/ui-react/with-schemas/index.js +1 -1
- package/min/ui-react/with-schemas/index.js.gz +0 -0
- package/min/ui-react-dom/index.js +1 -1
- package/min/ui-react-dom/index.js.gz +0 -0
- package/min/ui-react-dom/with-schemas/index.js +1 -1
- package/min/ui-react-dom/with-schemas/index.js.gz +0 -0
- package/min/ui-react-inspector/index.js +1 -1
- package/min/ui-react-inspector/index.js.gz +0 -0
- package/min/ui-react-inspector/with-schemas/index.js +1 -1
- package/min/ui-react-inspector/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/omni/index.js +2178 -1203
- package/omni/with-schemas/index.js +2178 -1203
- package/package.json +91 -11
- package/persisters/index.js +16 -10
- package/persisters/persister-automerge/index.js +15 -9
- package/persisters/persister-automerge/with-schemas/index.js +15 -9
- package/persisters/persister-browser/index.js +41 -9
- package/persisters/persister-browser/with-schemas/index.js +41 -9
- package/persisters/persister-cr-sqlite-wasm/index.js +16 -10
- package/persisters/persister-cr-sqlite-wasm/with-schemas/index.js +16 -10
- package/persisters/persister-durable-object-sql-storage/index.js +16 -10
- package/persisters/persister-durable-object-sql-storage/with-schemas/index.js +16 -10
- package/persisters/persister-durable-object-storage/index.js +14 -8
- package/persisters/persister-durable-object-storage/with-schemas/index.js +14 -8
- package/persisters/persister-electric-sql/index.js +16 -10
- package/persisters/persister-electric-sql/with-schemas/index.js +16 -10
- package/persisters/persister-expo-sqlite/index.js +16 -10
- package/persisters/persister-expo-sqlite/with-schemas/index.js +16 -10
- package/persisters/persister-file/index.js +14 -8
- package/persisters/persister-file/with-schemas/index.js +14 -8
- package/persisters/persister-indexed-db/index.js +14 -8
- package/persisters/persister-indexed-db/with-schemas/index.js +14 -8
- package/persisters/persister-libsql/index.js +16 -10
- package/persisters/persister-libsql/with-schemas/index.js +16 -10
- package/persisters/persister-partykit-client/index.js +14 -8
- package/persisters/persister-partykit-client/with-schemas/index.js +14 -8
- package/persisters/persister-partykit-server/index.js +7 -3
- package/persisters/persister-partykit-server/with-schemas/index.js +7 -3
- package/persisters/persister-pglite/index.js +15 -9
- package/persisters/persister-pglite/with-schemas/index.js +15 -9
- package/persisters/persister-postgres/index.js +15 -9
- package/persisters/persister-postgres/with-schemas/index.js +15 -9
- package/persisters/persister-powersync/index.js +16 -10
- package/persisters/persister-powersync/with-schemas/index.js +16 -10
- package/persisters/persister-react-native-mmkv/index.js +465 -0
- package/persisters/persister-react-native-mmkv/with-schemas/index.js +465 -0
- package/persisters/persister-react-native-sqlite/index.js +1195 -0
- package/persisters/persister-react-native-sqlite/with-schemas/index.js +1195 -0
- package/persisters/persister-remote/index.js +16 -10
- package/persisters/persister-remote/with-schemas/index.js +16 -10
- package/persisters/persister-sqlite-bun/index.js +16 -10
- package/persisters/persister-sqlite-bun/with-schemas/index.js +16 -10
- package/persisters/persister-sqlite-wasm/index.js +16 -10
- package/persisters/persister-sqlite-wasm/with-schemas/index.js +16 -10
- package/persisters/persister-sqlite3/index.js +16 -10
- package/persisters/persister-sqlite3/with-schemas/index.js +16 -10
- package/persisters/persister-yjs/index.js +20 -12
- package/persisters/persister-yjs/with-schemas/index.js +20 -12
- package/persisters/with-schemas/index.js +16 -10
- package/queries/index.js +20 -12
- package/queries/with-schemas/index.js +20 -12
- package/readme.md +13 -13
- package/relationships/index.js +10 -5
- package/relationships/with-schemas/index.js +10 -5
- package/releases.md +179 -41
- package/store/index.js +50 -18
- package/store/with-schemas/index.js +50 -18
- package/synchronizers/index.js +16 -10
- package/synchronizers/synchronizer-broadcast-channel/index.js +17 -11
- package/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js +17 -11
- package/synchronizers/synchronizer-local/index.js +17 -11
- package/synchronizers/synchronizer-local/with-schemas/index.js +17 -11
- package/synchronizers/synchronizer-ws-client/index.js +16 -10
- package/synchronizers/synchronizer-ws-client/with-schemas/index.js +16 -10
- package/synchronizers/synchronizer-ws-server/index.js +16 -10
- package/synchronizers/synchronizer-ws-server/with-schemas/index.js +16 -10
- package/synchronizers/synchronizer-ws-server-durable-object/index.js +16 -10
- package/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +16 -10
- package/synchronizers/synchronizer-ws-server-simple/index.js +8 -4
- package/synchronizers/synchronizer-ws-server-simple/with-schemas/index.js +8 -4
- package/synchronizers/with-schemas/index.js +16 -10
- package/ui-react/index.js +408 -374
- package/ui-react/with-schemas/index.js +408 -374
- package/ui-react-dom/index.js +883 -437
- package/ui-react-dom/with-schemas/index.js +883 -437
- package/ui-react-inspector/index.js +1761 -556
- package/ui-react-inspector/with-schemas/index.js +1761 -556
- package/with-schemas/index.js +63 -31
|
@@ -32,8 +32,7 @@ import type {DatabasePersisterConfig, Persister, Persists} from '../index.d.ts';
|
|
|
32
32
|
* @category Persister
|
|
33
33
|
* @since v4.5.0
|
|
34
34
|
*/
|
|
35
|
-
export interface ExpoSqlitePersister
|
|
36
|
-
extends Persister<Persists.StoreOrMergeableStore> {
|
|
35
|
+
export interface ExpoSqlitePersister extends Persister<Persists.StoreOrMergeableStore> {
|
|
37
36
|
/**
|
|
38
37
|
* The getDb method returns a reference to the database instance the Store is
|
|
39
38
|
* being persisted to.
|
|
@@ -87,6 +86,10 @@ export interface ExpoSqlitePersister
|
|
|
87
86
|
*
|
|
88
87
|
* See the documentation for the DpcJson and DpcTabular types for more
|
|
89
88
|
* information on how both of those modes can be configured.
|
|
89
|
+
*
|
|
90
|
+
* Note: When using tabular mode, SQL NULL values are loaded as TinyBase null
|
|
91
|
+
* values, making tables dense (every Row has every Cell). See the Database
|
|
92
|
+
* Persistence guide for details.
|
|
90
93
|
* @param store The Store or MergeableStore to persist.
|
|
91
94
|
* @param db The database instance that was returned from
|
|
92
95
|
* `SQLite.openDatabase(...)`.
|
|
@@ -39,8 +39,9 @@ import type {
|
|
|
39
39
|
* @category Persister
|
|
40
40
|
* @since v4.5.0
|
|
41
41
|
*/
|
|
42
|
-
export interface ExpoSqlitePersister<
|
|
43
|
-
extends
|
|
42
|
+
export interface ExpoSqlitePersister<
|
|
43
|
+
Schemas extends OptionalSchemas,
|
|
44
|
+
> extends Persister<Schemas, Persists.StoreOrMergeableStore> {
|
|
44
45
|
/**
|
|
45
46
|
* The getDb method returns a reference to the database instance the Store is
|
|
46
47
|
* being persisted to.
|
|
@@ -106,6 +107,10 @@ export interface ExpoSqlitePersister<Schemas extends OptionalSchemas>
|
|
|
106
107
|
*
|
|
107
108
|
* See the documentation for the DpcJson and DpcTabular types for more
|
|
108
109
|
* information on how both of those modes can be configured.
|
|
110
|
+
*
|
|
111
|
+
* Note: When using tabular mode, SQL NULL values are loaded as TinyBase null
|
|
112
|
+
* values, making tables dense (every Row has every Cell). See the Database
|
|
113
|
+
* Persistence guide for details.
|
|
109
114
|
* @param store The Store or MergeableStore to persist.
|
|
110
115
|
* @param db The database instance that was returned from
|
|
111
116
|
* `SQLite.openDatabase(...)`.
|
|
@@ -23,8 +23,7 @@ import type {Persister, Persists} from '../index.d.ts';
|
|
|
23
23
|
* @category Persister
|
|
24
24
|
* @since v4.3.14
|
|
25
25
|
*/
|
|
26
|
-
export interface FilePersister
|
|
27
|
-
extends Persister<Persists.StoreOrMergeableStore> {
|
|
26
|
+
export interface FilePersister extends Persister<Persists.StoreOrMergeableStore> {
|
|
28
27
|
/**
|
|
29
28
|
* The getFilePath method returns the location of the local file the Store is
|
|
30
29
|
* being persisted to.
|
|
@@ -26,8 +26,9 @@ import type {Persister, Persists} from '../../with-schemas/index.d.ts';
|
|
|
26
26
|
* @category Persister
|
|
27
27
|
* @since v4.3.14
|
|
28
28
|
*/
|
|
29
|
-
export interface FilePersister<
|
|
30
|
-
extends
|
|
29
|
+
export interface FilePersister<
|
|
30
|
+
Schemas extends OptionalSchemas,
|
|
31
|
+
> extends Persister<Schemas, Persists.StoreOrMergeableStore> {
|
|
31
32
|
/**
|
|
32
33
|
* The getFilePath method returns the location of the local file the Store is
|
|
33
34
|
* being persisted to.
|
|
@@ -25,8 +25,9 @@ import type {Persister} from '../../with-schemas/index.d.ts';
|
|
|
25
25
|
* @category Persister
|
|
26
26
|
* @since v4.3.14
|
|
27
27
|
*/
|
|
28
|
-
export interface IndexedDbPersister<
|
|
29
|
-
extends
|
|
28
|
+
export interface IndexedDbPersister<
|
|
29
|
+
Schemas extends OptionalSchemas,
|
|
30
|
+
> extends Persister<Schemas> {
|
|
30
31
|
/**
|
|
31
32
|
* The getDbName method returns the unique key of the IndexedDB the Store is
|
|
32
33
|
* being persisted to.
|
|
@@ -74,6 +74,10 @@ export interface LibSqlPersister extends Persister {
|
|
|
74
74
|
*
|
|
75
75
|
* See the documentation for the DpcJson and DpcTabular types for more
|
|
76
76
|
* information on how both of those modes can be configured.
|
|
77
|
+
*
|
|
78
|
+
* Note: When using tabular mode, SQL NULL values are loaded as TinyBase null
|
|
79
|
+
* values, making tables dense (every Row has every Cell). See the Database
|
|
80
|
+
* Persistence guide for details.
|
|
77
81
|
* @param store The Store to persist.
|
|
78
82
|
* @param client The database client that was returned from `createClient(...)`.
|
|
79
83
|
* @param configOrStoreTableName A DatabasePersisterConfig to configure the
|
|
@@ -30,8 +30,9 @@ import type {
|
|
|
30
30
|
* @category Persister
|
|
31
31
|
* @since v4.7.0
|
|
32
32
|
*/
|
|
33
|
-
export interface LibSqlPersister<
|
|
34
|
-
extends
|
|
33
|
+
export interface LibSqlPersister<
|
|
34
|
+
Schemas extends OptionalSchemas,
|
|
35
|
+
> extends Persister<Schemas> {
|
|
35
36
|
/**
|
|
36
37
|
* The getClient method returns a reference to the database client the Store
|
|
37
38
|
* is being persisted to.
|
|
@@ -93,6 +94,10 @@ export interface LibSqlPersister<Schemas extends OptionalSchemas>
|
|
|
93
94
|
*
|
|
94
95
|
* See the documentation for the DpcJson and DpcTabular types for more
|
|
95
96
|
* information on how both of those modes can be configured.
|
|
97
|
+
*
|
|
98
|
+
* Note: When using tabular mode, SQL NULL values are loaded as TinyBase null
|
|
99
|
+
* values, making tables dense (every Row has every Cell). See the Database
|
|
100
|
+
* Persistence guide for details.
|
|
96
101
|
* @param store The Store to persist.
|
|
97
102
|
* @param client The database client that was returned from `createClient(...)`.
|
|
98
103
|
* @param configOrStoreTableName A DatabasePersisterConfig to configure the
|
|
@@ -38,8 +38,9 @@ import type {Persister} from '../../with-schemas/index.d.ts';
|
|
|
38
38
|
* @category Persister
|
|
39
39
|
* @since v4.3.14
|
|
40
40
|
*/
|
|
41
|
-
export interface PartyKitPersister<
|
|
42
|
-
extends
|
|
41
|
+
export interface PartyKitPersister<
|
|
42
|
+
Schemas extends OptionalSchemas,
|
|
43
|
+
> extends Persister<Schemas> {
|
|
43
44
|
/**
|
|
44
45
|
* The getConnection method returns the PartySocket the Store is being
|
|
45
46
|
* persisted to.
|
|
@@ -24,8 +24,7 @@ import type {DatabasePersisterConfig, Persister, Persists} from '../index.d.ts';
|
|
|
24
24
|
* @category Persister
|
|
25
25
|
* @since 5.2.0
|
|
26
26
|
*/
|
|
27
|
-
export interface PglitePersister
|
|
28
|
-
extends Persister<Persists.StoreOrMergeableStore> {
|
|
27
|
+
export interface PglitePersister extends Persister<Persists.StoreOrMergeableStore> {
|
|
29
28
|
/**
|
|
30
29
|
* The getPglite method returns a reference to the database connection the
|
|
31
30
|
* Store is being persisted to.
|
|
@@ -82,7 +81,11 @@ export interface PglitePersister
|
|
|
82
81
|
* See the documentation for the DpcJson and DpcTabular types for more
|
|
83
82
|
* information on how both of those modes can be configured.
|
|
84
83
|
*
|
|
85
|
-
*
|
|
84
|
+
* Note: When using tabular mode, SQL NULL values are loaded as TinyBase null
|
|
85
|
+
* values, making tables dense (every Row has every Cell). See the Database
|
|
86
|
+
* Persistence guide for details.
|
|
87
|
+
*
|
|
88
|
+
* This method is asynchronous because it will await the completion of the
|
|
86
89
|
* new connections to the database. You will need to `await` a call to this
|
|
87
90
|
* function or handle the return type natively as a Promise.
|
|
88
91
|
* @param store The Store or MergeableStore to persist.
|
|
@@ -166,6 +169,7 @@ export interface PglitePersister
|
|
|
166
169
|
* await pglite.close();
|
|
167
170
|
* ```
|
|
168
171
|
* @category Creation
|
|
172
|
+
* @essential Persisting stores
|
|
169
173
|
* @since 5.2.0
|
|
170
174
|
*/
|
|
171
175
|
export function createPglitePersister(
|
|
@@ -31,8 +31,9 @@ import type {
|
|
|
31
31
|
* @category Persister
|
|
32
32
|
* @since 5.2.0
|
|
33
33
|
*/
|
|
34
|
-
export interface PglitePersister<
|
|
35
|
-
extends
|
|
34
|
+
export interface PglitePersister<
|
|
35
|
+
Schemas extends OptionalSchemas,
|
|
36
|
+
> extends Persister<Schemas, Persists.StoreOrMergeableStore> {
|
|
36
37
|
/**
|
|
37
38
|
* The getPglite method returns a reference to the database connection the
|
|
38
39
|
* Store is being persisted to.
|
|
@@ -101,7 +102,11 @@ export interface PglitePersister<Schemas extends OptionalSchemas>
|
|
|
101
102
|
* See the documentation for the DpcJson and DpcTabular types for more
|
|
102
103
|
* information on how both of those modes can be configured.
|
|
103
104
|
*
|
|
104
|
-
*
|
|
105
|
+
* Note: When using tabular mode, SQL NULL values are loaded as TinyBase null
|
|
106
|
+
* values, making tables dense (every Row has every Cell). See the Database
|
|
107
|
+
* Persistence guide for details.
|
|
108
|
+
*
|
|
109
|
+
* This method is asynchronous because it will await the completion of the
|
|
105
110
|
* new connections to the database. You will need to `await` a call to this
|
|
106
111
|
* function or handle the return type natively as a Promise.
|
|
107
112
|
* @param store The Store or MergeableStore to persist.
|
|
@@ -185,6 +190,7 @@ export interface PglitePersister<Schemas extends OptionalSchemas>
|
|
|
185
190
|
* await pglite.close();
|
|
186
191
|
* ```
|
|
187
192
|
* @category Creation
|
|
193
|
+
* @essential Persisting stores
|
|
188
194
|
* @since 5.2.0
|
|
189
195
|
*/
|
|
190
196
|
export function createPglitePersister<Schemas extends OptionalSchemas>(
|
|
@@ -24,8 +24,7 @@ import type {DatabasePersisterConfig, Persister, Persists} from '../index.d.ts';
|
|
|
24
24
|
* @category Persister
|
|
25
25
|
* @since 5.2.0
|
|
26
26
|
*/
|
|
27
|
-
export interface PostgresPersister
|
|
28
|
-
extends Persister<Persists.StoreOrMergeableStore> {
|
|
27
|
+
export interface PostgresPersister extends Persister<Persists.StoreOrMergeableStore> {
|
|
29
28
|
/**
|
|
30
29
|
* The getSql method returns a reference to the database connection the Store
|
|
31
30
|
* is being persisted to.
|
|
@@ -78,6 +77,10 @@ export interface PostgresPersister
|
|
|
78
77
|
* See the documentation for the DpcJson and DpcTabular types for more
|
|
79
78
|
* information on how both of those modes can be configured.
|
|
80
79
|
*
|
|
80
|
+
* Note: When using tabular mode, SQL NULL values are loaded as TinyBase null
|
|
81
|
+
* values, making tables dense (every Row has every Cell). See the Database
|
|
82
|
+
* Persistence guide for details.
|
|
83
|
+
*
|
|
81
84
|
* This method is asynchronous because it will await the creation of dedicated
|
|
82
85
|
* new connections to the database. You will need to `await` a call to this
|
|
83
86
|
* function or handle the return type natively as a Promise.
|
|
@@ -31,8 +31,9 @@ import type {
|
|
|
31
31
|
* @category Persister
|
|
32
32
|
* @since 5.2.0
|
|
33
33
|
*/
|
|
34
|
-
export interface PostgresPersister<
|
|
35
|
-
extends
|
|
34
|
+
export interface PostgresPersister<
|
|
35
|
+
Schemas extends OptionalSchemas,
|
|
36
|
+
> extends Persister<Schemas, Persists.StoreOrMergeableStore> {
|
|
36
37
|
/**
|
|
37
38
|
* The getSql method returns a reference to the database connection the Store
|
|
38
39
|
* is being persisted to.
|
|
@@ -97,6 +98,10 @@ export interface PostgresPersister<Schemas extends OptionalSchemas>
|
|
|
97
98
|
* See the documentation for the DpcJson and DpcTabular types for more
|
|
98
99
|
* information on how both of those modes can be configured.
|
|
99
100
|
*
|
|
101
|
+
* Note: When using tabular mode, SQL NULL values are loaded as TinyBase null
|
|
102
|
+
* values, making tables dense (every Row has every Cell). See the Database
|
|
103
|
+
* Persistence guide for details.
|
|
104
|
+
*
|
|
100
105
|
* This method is asynchronous because it will await the creation of dedicated
|
|
101
106
|
* new connections to the database. You will need to `await` a call to this
|
|
102
107
|
* function or handle the return type natively as a Promise.
|
|
@@ -76,6 +76,10 @@ export interface PowerSyncPersister extends Persister {
|
|
|
76
76
|
*
|
|
77
77
|
* See the documentation for the DpcJson and DpcTabular types for more
|
|
78
78
|
* information on how both of those modes can be configured.
|
|
79
|
+
*
|
|
80
|
+
* Note: When using tabular mode, SQL NULL values are loaded as TinyBase null
|
|
81
|
+
* values, making tables dense (every Row has every Cell). See the Database
|
|
82
|
+
* Persistence guide for details.
|
|
79
83
|
* @param store The Store to persist.
|
|
80
84
|
* @param powerSync The PowerSync instance.
|
|
81
85
|
* @param configOrStoreTableName A DatabasePersisterConfig to configure the
|
|
@@ -31,8 +31,9 @@ import type {
|
|
|
31
31
|
* @category Persister
|
|
32
32
|
* @since v4.8.0
|
|
33
33
|
*/
|
|
34
|
-
export interface PowerSyncPersister<
|
|
35
|
-
extends
|
|
34
|
+
export interface PowerSyncPersister<
|
|
35
|
+
Schemas extends OptionalSchemas,
|
|
36
|
+
> extends Persister<Schemas> {
|
|
36
37
|
/**
|
|
37
38
|
* The getPowerSync method returns a reference to the PowerSync instance the
|
|
38
39
|
* Store is being persisted to.
|
|
@@ -95,6 +96,10 @@ export interface PowerSyncPersister<Schemas extends OptionalSchemas>
|
|
|
95
96
|
*
|
|
96
97
|
* See the documentation for the DpcJson and DpcTabular types for more
|
|
97
98
|
* information on how both of those modes can be configured.
|
|
99
|
+
*
|
|
100
|
+
* Note: When using tabular mode, SQL NULL values are loaded as TinyBase null
|
|
101
|
+
* values, making tables dense (every Row has every Cell). See the Database
|
|
102
|
+
* Persistence guide for details.
|
|
98
103
|
* @param store The Store to persist.
|
|
99
104
|
* @param powerSync The PowerSync instance.
|
|
100
105
|
* @param configOrStoreTableName A DatabasePersisterConfig to configure the
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The persister-react-native-mmkv module of the TinyBase project lets you save
|
|
3
|
+
* and load Store data to and from a MMKV storage using the
|
|
4
|
+
* [`react-native-mmkv`](https://github.com/mrousavy/react-native-mmkv) module
|
|
5
|
+
* (in an appropriate React Native environment).
|
|
6
|
+
* @see Database Persistence guide
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
* @module persister-react-native-mmkv
|
|
9
|
+
* @since v6.5.0
|
|
10
|
+
*/
|
|
11
|
+
import type {MMKV} from 'react-native-mmkv';
|
|
12
|
+
import type {MergeableStore} from '../../mergeable-store/index.d.ts';
|
|
13
|
+
import type {Store} from '../../store/index.d.ts';
|
|
14
|
+
import type {Persister, Persists} from '../index.d.ts';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The ReactNativeMmkvPersister interface represents a Persister that lets you
|
|
18
|
+
* save and load Store data to and from a `react-native-mmkv` storage.
|
|
19
|
+
*
|
|
20
|
+
* You should use the createReactNativeMmkvPersister function to create a
|
|
21
|
+
* ReactNativeMmkvPersister object.
|
|
22
|
+
*
|
|
23
|
+
* It is a minor extension to the Persister interface and simply provides an
|
|
24
|
+
* extra getStorageName method for accessing the unique key of the storage
|
|
25
|
+
* location the Store is being persisted to.
|
|
26
|
+
* @category Persister
|
|
27
|
+
* @since v6.5.0
|
|
28
|
+
*/
|
|
29
|
+
export interface ReactNativeMmkvPersister extends Persister<Persists.StoreOrMergeableStore> {
|
|
30
|
+
/**
|
|
31
|
+
* The getStorageName method returns the unique key of the storage location the
|
|
32
|
+
* Store is being persisted to.
|
|
33
|
+
* @returns The unique key of the storage location.
|
|
34
|
+
* @example
|
|
35
|
+
* This example creates a Persister object against a newly-created Store and
|
|
36
|
+
* then gets the unique key of the storage location back out again.
|
|
37
|
+
*
|
|
38
|
+
* ```js yolo
|
|
39
|
+
* import {createMMKV} from 'react-native-mmkv';
|
|
40
|
+
* import {createStore} from 'tinybase';
|
|
41
|
+
* import {createReactNativeMmkvPersister} from 'tinybase/persisters/persister-react-native-mmkv';
|
|
42
|
+
*
|
|
43
|
+
* const storage = createMMKV();
|
|
44
|
+
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
45
|
+
* const persister = createReactNativeMmkvPersister(
|
|
46
|
+
* store,
|
|
47
|
+
* storage,
|
|
48
|
+
* 'my_tinybase',
|
|
49
|
+
* );
|
|
50
|
+
* console.log(persister.getStorageName() == 'my_tinybase');
|
|
51
|
+
* // -> true
|
|
52
|
+
*
|
|
53
|
+
* await persister.destroy();
|
|
54
|
+
* ```
|
|
55
|
+
* @category Getter
|
|
56
|
+
* @since v6.5.0
|
|
57
|
+
*/
|
|
58
|
+
getStorageName(): string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The createReactNativeMmkvPersister function creates a
|
|
63
|
+
* ReactNativeMmkvPersister object that can persist the Store to a local
|
|
64
|
+
* `react-native-mmkv` storage.
|
|
65
|
+
*
|
|
66
|
+
* A ReactNativeMmkvPersister supports both regular Store and MergeableStore
|
|
67
|
+
* objects.
|
|
68
|
+
*
|
|
69
|
+
* As well as providing a reference to the Store to persist, you must provide a
|
|
70
|
+
* `storage` parameter which identifies the MMKV storage instance.
|
|
71
|
+
*
|
|
72
|
+
* The third argument is a `storageName` string that configures which key to use
|
|
73
|
+
* for the storage key.
|
|
74
|
+
* @param store The Store or MergeableStore to persist.
|
|
75
|
+
* @param storage The MMKV storage instance.
|
|
76
|
+
* @param storageName The unique key to identify the storage location.
|
|
77
|
+
* @param onIgnoredError An optional handler for the errors that the Persister
|
|
78
|
+
* would otherwise ignore when trying to save or load data. This is suitable for
|
|
79
|
+
* debugging persistence issues in a development environment.
|
|
80
|
+
* @returns A reference to the new ReactNativeMmkvPersister object.
|
|
81
|
+
* @example
|
|
82
|
+
* This example creates a ReactNativeMmkvPersister object and persists the
|
|
83
|
+
* Store to a MMKV storage instance as a JSON serialization into the
|
|
84
|
+
* `my_tinybase` key. It makes a change to the storage directly and then
|
|
85
|
+
* reloads it back into the Store.
|
|
86
|
+
*
|
|
87
|
+
* ```js yolo
|
|
88
|
+
* import {createMMKV} from 'react-native-mmkv';
|
|
89
|
+
* import {createStore} from 'tinybase';
|
|
90
|
+
* import {createReactNativeMmkvPersister} from 'tinybase/persisters/persister-react-native-mmkv';
|
|
91
|
+
*
|
|
92
|
+
* const storage = createMMKV();
|
|
93
|
+
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
94
|
+
* const persister = createReactNativeMmkvPersister(
|
|
95
|
+
* store,
|
|
96
|
+
* storage,
|
|
97
|
+
* 'my_tinybase',
|
|
98
|
+
* );
|
|
99
|
+
*
|
|
100
|
+
* await persister.save();
|
|
101
|
+
* // Store will be saved to the MMKV storage.
|
|
102
|
+
*
|
|
103
|
+
* console.log(storage.getString('my_tinybase'));
|
|
104
|
+
* // -> '[{"pets":{"fido":{"species":"dog"}}},{}]'
|
|
105
|
+
*
|
|
106
|
+
* await persister.destroy();
|
|
107
|
+
* storage.delete('my_tinybase');
|
|
108
|
+
* ```
|
|
109
|
+
* @category Creation
|
|
110
|
+
* @since v6.5.0
|
|
111
|
+
*/
|
|
112
|
+
export function createReactNativeMmkvPersister(
|
|
113
|
+
store: Store | MergeableStore,
|
|
114
|
+
storage: MMKV,
|
|
115
|
+
storageName?: string,
|
|
116
|
+
onIgnoredError?: (error: any) => void,
|
|
117
|
+
): ReactNativeMmkvPersister;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The persister-react-native-mmkv module of the TinyBase project lets you save
|
|
3
|
+
* and load Store data to and from a MMKV storage using the
|
|
4
|
+
* [`react-native-mmkv`](https://github.com/mrousavy/react-native-mmkv) module
|
|
5
|
+
* (in an appropriate React Native environment).
|
|
6
|
+
* @see Database Persistence guide
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
* @module persister-react-native-mmkv
|
|
9
|
+
* @since v6.5.0
|
|
10
|
+
*/
|
|
11
|
+
import type {MMKV} from 'react-native-mmkv';
|
|
12
|
+
import type {MergeableStore} from '../../../mergeable-store/with-schemas/index.d.ts';
|
|
13
|
+
import type {
|
|
14
|
+
OptionalSchemas,
|
|
15
|
+
Store,
|
|
16
|
+
} from '../../../store/with-schemas/index.d.ts';
|
|
17
|
+
import type {Persister, Persists} from '../../with-schemas/index.d.ts';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The ReactNativeMmkvPersister interface represents a Persister that lets you
|
|
21
|
+
* save and load Store data to and from a `react-native-mmkv` storage.
|
|
22
|
+
*
|
|
23
|
+
* You should use the createReactNativeMmkvPersister function to create a
|
|
24
|
+
* ReactNativeMmkvPersister object.
|
|
25
|
+
*
|
|
26
|
+
* It is a minor extension to the Persister interface and simply provides an
|
|
27
|
+
* extra getStorageName method for accessing the unique key of the storage
|
|
28
|
+
* location the Store is being persisted to.
|
|
29
|
+
* @category Persister
|
|
30
|
+
* @since v6.5.0
|
|
31
|
+
*/
|
|
32
|
+
export interface ReactNativeMmkvPersister<
|
|
33
|
+
Schemas extends OptionalSchemas,
|
|
34
|
+
> extends Persister<Schemas, Persists.StoreOrMergeableStore> {
|
|
35
|
+
/**
|
|
36
|
+
* The getStorageName method returns the unique key of the storage location the
|
|
37
|
+
* Store is being persisted to.
|
|
38
|
+
* @returns The unique key of the storage location.
|
|
39
|
+
* @example
|
|
40
|
+
* This example creates a Persister object against a newly-created Store and
|
|
41
|
+
* then gets the unique key of the storage location back out again.
|
|
42
|
+
*
|
|
43
|
+
* ```js yolo
|
|
44
|
+
* import {createMMKV} from 'react-native-mmkv';
|
|
45
|
+
* import {createStore} from 'tinybase';
|
|
46
|
+
* import {createReactNativeMmkvPersister} from 'tinybase/persisters/persister-react-native-mmkv';
|
|
47
|
+
*
|
|
48
|
+
* const storage = createMMKV();
|
|
49
|
+
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
50
|
+
* const persister = createReactNativeMmkvPersister(
|
|
51
|
+
* store,
|
|
52
|
+
* storage,
|
|
53
|
+
* 'my_tinybase',
|
|
54
|
+
* );
|
|
55
|
+
* console.log(persister.getStorageName() == 'my_tinybase');
|
|
56
|
+
* // -> true
|
|
57
|
+
*
|
|
58
|
+
* await persister.destroy();
|
|
59
|
+
* ```
|
|
60
|
+
* @category Getter
|
|
61
|
+
* @since v6.5.0
|
|
62
|
+
*/
|
|
63
|
+
getStorageName(): string;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The createReactNativeMmkvPersister function creates a
|
|
68
|
+
* ReactNativeMmkvPersister object that can persist the Store to a local
|
|
69
|
+
* `react-native-mmkv` storage.
|
|
70
|
+
*
|
|
71
|
+
* This has schema-based typing. The following is a simplified representation:
|
|
72
|
+
*
|
|
73
|
+
* ```ts override
|
|
74
|
+
* createReactNativeMmkvPersister(
|
|
75
|
+
* store: Store | MergeableStore,
|
|
76
|
+
* storage: MMKV,
|
|
77
|
+
* storageName?: string,
|
|
78
|
+
* onIgnoredError?: (error: any) => void,
|
|
79
|
+
* ): ReactNativeMmkvPersister;
|
|
80
|
+
* ```
|
|
81
|
+
*
|
|
82
|
+
* A ReactNativeMmkvPersister supports both regular Store and MergeableStore
|
|
83
|
+
* objects.
|
|
84
|
+
*
|
|
85
|
+
* As well as providing a reference to the Store to persist, you must provide a
|
|
86
|
+
* `storage` parameter which identifies the MMKV storage instance.
|
|
87
|
+
*
|
|
88
|
+
* The third argument is a `storageName` string that configures which key to use
|
|
89
|
+
* for the storage key.
|
|
90
|
+
* @param store The Store or MergeableStore to persist.
|
|
91
|
+
* @param storage The MMKV storage instance.
|
|
92
|
+
* @param storageName The unique key to identify the storage location.
|
|
93
|
+
* @param onIgnoredError An optional handler for the errors that the Persister
|
|
94
|
+
* would otherwise ignore when trying to save or load data. This is suitable for
|
|
95
|
+
* debugging persistence issues in a development environment.
|
|
96
|
+
* @returns A reference to the new ReactNativeMmkvPersister object.
|
|
97
|
+
* @example
|
|
98
|
+
* This example creates a ReactNativeMmkvPersister object and persists the
|
|
99
|
+
* Store to a MMKV storage instance as a JSON serialization into the
|
|
100
|
+
* `my_tinybase` key. It makes a change to the storage directly and then
|
|
101
|
+
* reloads it back into the Store.
|
|
102
|
+
*
|
|
103
|
+
* ```js yolo
|
|
104
|
+
* import {createMMKV} from 'react-native-mmkv';
|
|
105
|
+
* import {createStore} from 'tinybase';
|
|
106
|
+
* import {createReactNativeMmkvPersister} from 'tinybase/persisters/persister-react-native-mmkv';
|
|
107
|
+
*
|
|
108
|
+
* const storage = createMMKV();
|
|
109
|
+
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
110
|
+
* const persister = createReactNativeMmkvPersister(
|
|
111
|
+
* store,
|
|
112
|
+
* storage,
|
|
113
|
+
* 'my_tinybase',
|
|
114
|
+
* );
|
|
115
|
+
*
|
|
116
|
+
* await persister.save();
|
|
117
|
+
* // Store will be saved to the MMKV storage.
|
|
118
|
+
*
|
|
119
|
+
* console.log(storage.getString('my_tinybase'));
|
|
120
|
+
* // -> '[{"pets":{"fido":{"species":"dog"}}},{}]'
|
|
121
|
+
*
|
|
122
|
+
* await persister.destroy();
|
|
123
|
+
* storage.delete('my_tinybase');
|
|
124
|
+
* ```
|
|
125
|
+
* @category Creation
|
|
126
|
+
* @since v6.5.0
|
|
127
|
+
*/
|
|
128
|
+
export function createReactNativeMmkvPersister<Schemas extends OptionalSchemas>(
|
|
129
|
+
store: Store<Schemas> | MergeableStore<Schemas>,
|
|
130
|
+
storage: MMKV,
|
|
131
|
+
storageName?: string,
|
|
132
|
+
onIgnoredError?: (error: any) => void,
|
|
133
|
+
): ReactNativeMmkvPersister<Schemas>;
|