pomegranate-db 0.1.0
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/LICENSE +21 -0
- package/NOTICE.md +38 -0
- package/PomegranateDB.podspec +67 -0
- package/README.md +122 -0
- package/dist/adapters/expo-sqlite/ExpoSQLiteDriver.d.ts +34 -0
- package/dist/adapters/expo-sqlite/ExpoSQLiteDriver.js +155 -0
- package/dist/adapters/expo-sqlite/index.d.ts +2 -0
- package/dist/adapters/expo-sqlite/index.js +6 -0
- package/dist/adapters/index.d.ts +7 -0
- package/dist/adapters/index.js +13 -0
- package/dist/adapters/loki/LokiAdapter.d.ts +100 -0
- package/dist/adapters/loki/LokiAdapter.js +144 -0
- package/dist/adapters/loki/index.d.ts +6 -0
- package/dist/adapters/loki/index.js +12 -0
- package/dist/adapters/loki/worker/LokiDispatcher.d.ts +21 -0
- package/dist/adapters/loki/worker/LokiDispatcher.js +63 -0
- package/dist/adapters/loki/worker/LokiExecutor.d.ts +96 -0
- package/dist/adapters/loki/worker/LokiExecutor.js +462 -0
- package/dist/adapters/loki/worker/SynchronousWorker.d.ts +22 -0
- package/dist/adapters/loki/worker/SynchronousWorker.js +76 -0
- package/dist/adapters/loki/worker/loki.worker.d.ts +14 -0
- package/dist/adapters/loki/worker/loki.worker.js +112 -0
- package/dist/adapters/loki/worker/types.d.ts +44 -0
- package/dist/adapters/loki/worker/types.js +11 -0
- package/dist/adapters/native-sqlite/NativeSQLiteDriver.d.ts +55 -0
- package/dist/adapters/native-sqlite/NativeSQLiteDriver.js +145 -0
- package/dist/adapters/native-sqlite/index.d.ts +2 -0
- package/dist/adapters/native-sqlite/index.js +6 -0
- package/dist/adapters/op-sqlite/OpSQLiteDriver.d.ts +49 -0
- package/dist/adapters/op-sqlite/OpSQLiteDriver.js +140 -0
- package/dist/adapters/op-sqlite/index.d.ts +2 -0
- package/dist/adapters/op-sqlite/index.js +6 -0
- package/dist/adapters/sqlite/SQLiteAdapter.d.ts +70 -0
- package/dist/adapters/sqlite/SQLiteAdapter.js +264 -0
- package/dist/adapters/sqlite/index.d.ts +2 -0
- package/dist/adapters/sqlite/index.js +6 -0
- package/dist/adapters/sqlite/sql.d.ts +35 -0
- package/dist/adapters/sqlite/sql.js +258 -0
- package/dist/adapters/types.d.ts +93 -0
- package/dist/adapters/types.js +9 -0
- package/dist/collection/Collection.d.ts +103 -0
- package/dist/collection/Collection.js +245 -0
- package/dist/collection/index.d.ts +2 -0
- package/dist/collection/index.js +6 -0
- package/dist/database/Database.d.ts +128 -0
- package/dist/database/Database.js +245 -0
- package/dist/database/index.d.ts +2 -0
- package/dist/database/index.js +6 -0
- package/dist/encryption/index.d.ts +62 -0
- package/dist/encryption/index.js +276 -0
- package/dist/encryption/nodeCrypto.d.ts +18 -0
- package/dist/encryption/nodeCrypto.js +25 -0
- package/dist/encryption/nodeCrypto.native.d.ts +13 -0
- package/dist/encryption/nodeCrypto.native.js +26 -0
- package/dist/expo.d.ts +12 -0
- package/dist/expo.js +32 -0
- package/dist/hooks/index.d.ts +115 -0
- package/dist/hooks/index.js +285 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +57 -0
- package/dist/model/Model.d.ts +92 -0
- package/dist/model/Model.js +251 -0
- package/dist/model/index.d.ts +2 -0
- package/dist/model/index.js +7 -0
- package/dist/observable/Subject.d.ts +60 -0
- package/dist/observable/Subject.js +132 -0
- package/dist/observable/index.d.ts +2 -0
- package/dist/observable/index.js +10 -0
- package/dist/query/QueryBuilder.d.ts +51 -0
- package/dist/query/QueryBuilder.js +165 -0
- package/dist/query/index.d.ts +2 -0
- package/dist/query/index.js +7 -0
- package/dist/query/types.d.ts +60 -0
- package/dist/query/types.js +9 -0
- package/dist/schema/builder.d.ts +68 -0
- package/dist/schema/builder.js +168 -0
- package/dist/schema/index.d.ts +2 -0
- package/dist/schema/index.js +7 -0
- package/dist/schema/types.d.ts +108 -0
- package/dist/schema/types.js +9 -0
- package/dist/sync/index.d.ts +2 -0
- package/dist/sync/index.js +6 -0
- package/dist/sync/sync.d.ts +15 -0
- package/dist/sync/sync.js +182 -0
- package/dist/sync/types.d.ts +41 -0
- package/dist/sync/types.js +6 -0
- package/dist/utils/index.d.ts +45 -0
- package/dist/utils/index.js +99 -0
- package/expo-plugin/index.d.ts +68 -0
- package/expo-plugin/index.js +83 -0
- package/native/android-jsi/build.gradle +45 -0
- package/native/android-jsi/src/main/AndroidManifest.xml +2 -0
- package/native/android-jsi/src/main/cpp/CMakeLists.txt +73 -0
- package/native/android-jsi/src/main/cpp/DatabasePlatformAndroid.cpp +107 -0
- package/native/android-jsi/src/main/cpp/DatabasePlatformAndroid.h +16 -0
- package/native/android-jsi/src/main/cpp/JSIInstaller.cpp +27 -0
- package/native/android-jsi/src/main/java/com/pomegranate/jsi/JSIInstaller.kt +43 -0
- package/native/android-jsi/src/main/java/com/pomegranate/jsi/PomegranateJSIModule.kt +39 -0
- package/native/android-jsi/src/main/java/com/pomegranate/jsi/PomegranateJSIPackage.kt +17 -0
- package/native/ios/DatabasePlatformIOS.mm +83 -0
- package/native/ios/PomegranateJSI.h +15 -0
- package/native/ios/PomegranateJSI.mm +59 -0
- package/native/shared/Database.cpp +283 -0
- package/native/shared/Database.h +84 -0
- package/native/shared/Sqlite.cpp +61 -0
- package/native/shared/Sqlite.h +67 -0
- package/native/shared/sqlite3/sqlite3.c +260493 -0
- package/native/shared/sqlite3/sqlite3.h +13583 -0
- package/package.json +127 -0
- package/react-native.config.js +28 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* LokiJS Adapter.
|
|
4
|
+
*
|
|
5
|
+
* In-memory database adapter using LokiJS, suitable for web and testing.
|
|
6
|
+
* Supports running LokiJS in a Web Worker for better UI performance.
|
|
7
|
+
*
|
|
8
|
+
* Architecture:
|
|
9
|
+
* - Direct mode (default): LokiExecutor runs in the main thread.
|
|
10
|
+
* - Worker mode: All operations are dispatched via postMessage to a Web Worker
|
|
11
|
+
* (or SynchronousWorker for testing) that runs LokiExecutor internally.
|
|
12
|
+
*
|
|
13
|
+
* ```
|
|
14
|
+
* LokiAdapter ──▶ LokiExecutor (direct mode)
|
|
15
|
+
* │
|
|
16
|
+
* └──▶ LokiDispatcher ──▶ [Worker] ──▶ LokiExecutor (worker mode)
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.LokiAdapter = void 0;
|
|
21
|
+
const LokiExecutor_1 = require("./worker/LokiExecutor");
|
|
22
|
+
const LokiDispatcher_1 = require("./worker/LokiDispatcher");
|
|
23
|
+
// Re-export for consumers
|
|
24
|
+
// ─── LokiJS Adapter ──────────────────────────────────────────────────────
|
|
25
|
+
class LokiAdapter {
|
|
26
|
+
_executor = null;
|
|
27
|
+
_dispatcher = null;
|
|
28
|
+
_config;
|
|
29
|
+
_initialized = false;
|
|
30
|
+
constructor(config) {
|
|
31
|
+
this._config = config;
|
|
32
|
+
if (config.worker) {
|
|
33
|
+
this._dispatcher = new LokiDispatcher_1.LokiDispatcher(config.worker);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
// ─── Initialize ──────────────────────────────────────────────────────
|
|
37
|
+
async initialize(schema) {
|
|
38
|
+
if (this._initialized)
|
|
39
|
+
return;
|
|
40
|
+
if (this._dispatcher) {
|
|
41
|
+
// Worker mode: send serializable config + schema to the worker
|
|
42
|
+
await this._dispatcher.call('setUp', [
|
|
43
|
+
{
|
|
44
|
+
databaseName: this._config.databaseName,
|
|
45
|
+
saveStrategy: this._config.saveStrategy,
|
|
46
|
+
autosaveInterval: this._config.autosaveInterval,
|
|
47
|
+
},
|
|
48
|
+
schema,
|
|
49
|
+
]);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
// Direct mode: create executor locally
|
|
53
|
+
this._executor = new LokiExecutor_1.LokiExecutor({
|
|
54
|
+
databaseName: this._config.databaseName,
|
|
55
|
+
saveStrategy: this._config.saveStrategy,
|
|
56
|
+
autosaveInterval: this._config.autosaveInterval,
|
|
57
|
+
persistenceAdapter: this._config.persistenceAdapter,
|
|
58
|
+
lokiInstance: this._config.lokiInstance,
|
|
59
|
+
});
|
|
60
|
+
await this._executor.initialize(schema);
|
|
61
|
+
}
|
|
62
|
+
this._initialized = true;
|
|
63
|
+
}
|
|
64
|
+
// ─── Delegation helper ──────────────────────────────────────────────
|
|
65
|
+
/**
|
|
66
|
+
* Route a command to either the local executor or the remote worker.
|
|
67
|
+
* In worker mode, arguments are serialized via postMessage (structured cloning).
|
|
68
|
+
* In direct mode, the executor method is called directly.
|
|
69
|
+
*/
|
|
70
|
+
_call(method, args) {
|
|
71
|
+
if (this._dispatcher) {
|
|
72
|
+
return this._dispatcher.call(method, args);
|
|
73
|
+
}
|
|
74
|
+
if (!this._executor)
|
|
75
|
+
throw new Error('Database not initialized');
|
|
76
|
+
return this._executor[method](...args);
|
|
77
|
+
}
|
|
78
|
+
// ─── Query ──────────────────────────────────────────────────────────
|
|
79
|
+
async find(query) {
|
|
80
|
+
return this._call('find', [query]);
|
|
81
|
+
}
|
|
82
|
+
async count(query) {
|
|
83
|
+
return this._call('count', [query]);
|
|
84
|
+
}
|
|
85
|
+
async findById(table, id) {
|
|
86
|
+
return this._call('findById', [table, id]);
|
|
87
|
+
}
|
|
88
|
+
// ─── Insert / Update / Delete ────────────────────────────────────────
|
|
89
|
+
async insert(table, raw) {
|
|
90
|
+
return this._call('insert', [table, raw]);
|
|
91
|
+
}
|
|
92
|
+
async update(table, raw) {
|
|
93
|
+
return this._call('update', [table, raw]);
|
|
94
|
+
}
|
|
95
|
+
async markAsDeleted(table, id) {
|
|
96
|
+
return this._call('markAsDeleted', [table, id]);
|
|
97
|
+
}
|
|
98
|
+
async destroyPermanently(table, id) {
|
|
99
|
+
return this._call('destroyPermanently', [table, id]);
|
|
100
|
+
}
|
|
101
|
+
// ─── Batch ──────────────────────────────────────────────────────────
|
|
102
|
+
async batch(operations) {
|
|
103
|
+
return this._call('batch', [operations]);
|
|
104
|
+
}
|
|
105
|
+
// ─── Search ──────────────────────────────────────────────────────────
|
|
106
|
+
async search(descriptor) {
|
|
107
|
+
return this._call('search', [descriptor]);
|
|
108
|
+
}
|
|
109
|
+
// ─── Sync helpers ──────────────────────────────────────────────────
|
|
110
|
+
async getLocalChanges(tables) {
|
|
111
|
+
return this._call('getLocalChanges', [tables]);
|
|
112
|
+
}
|
|
113
|
+
async applyRemoteChanges(changes) {
|
|
114
|
+
return this._call('applyRemoteChanges', [changes]);
|
|
115
|
+
}
|
|
116
|
+
async markAsSynced(table, ids) {
|
|
117
|
+
return this._call('markAsSynced', [table, ids]);
|
|
118
|
+
}
|
|
119
|
+
// ─── Schema version ──────────────────────────────────────────────────
|
|
120
|
+
async getSchemaVersion() {
|
|
121
|
+
return this._call('getSchemaVersion', []);
|
|
122
|
+
}
|
|
123
|
+
// ─── Migration ──────────────────────────────────────────────────────
|
|
124
|
+
async migrate(migrations) {
|
|
125
|
+
return this._call('migrate', [migrations]);
|
|
126
|
+
}
|
|
127
|
+
// ─── Reset ──────────────────────────────────────────────────────────
|
|
128
|
+
async reset() {
|
|
129
|
+
return this._call('reset', []);
|
|
130
|
+
}
|
|
131
|
+
// ─── Close ──────────────────────────────────────────────────────────
|
|
132
|
+
async close() {
|
|
133
|
+
if (this._dispatcher) {
|
|
134
|
+
await this._dispatcher.call('close', []);
|
|
135
|
+
this._dispatcher.terminate();
|
|
136
|
+
}
|
|
137
|
+
else if (this._executor) {
|
|
138
|
+
await this._executor.close();
|
|
139
|
+
}
|
|
140
|
+
this._initialized = false;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
exports.LokiAdapter = LokiAdapter;
|
|
144
|
+
//# sourceMappingURL=LokiAdapter.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { LokiAdapter } from './LokiAdapter';
|
|
2
|
+
export type { LokiAdapterConfig, LokiExecutorConfig } from './LokiAdapter';
|
|
3
|
+
export { LokiExecutor } from './worker/LokiExecutor';
|
|
4
|
+
export { LokiDispatcher } from './worker/LokiDispatcher';
|
|
5
|
+
export { SynchronousWorker } from './worker/SynchronousWorker';
|
|
6
|
+
export type { WorkerInterface, WorkerCommandType, WorkerAction, WorkerResponse, } from './worker/types';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SynchronousWorker = exports.LokiDispatcher = exports.LokiExecutor = exports.LokiAdapter = void 0;
|
|
4
|
+
var LokiAdapter_1 = require("./LokiAdapter");
|
|
5
|
+
Object.defineProperty(exports, "LokiAdapter", { enumerable: true, get: function () { return LokiAdapter_1.LokiAdapter; } });
|
|
6
|
+
var LokiExecutor_1 = require("./worker/LokiExecutor");
|
|
7
|
+
Object.defineProperty(exports, "LokiExecutor", { enumerable: true, get: function () { return LokiExecutor_1.LokiExecutor; } });
|
|
8
|
+
var LokiDispatcher_1 = require("./worker/LokiDispatcher");
|
|
9
|
+
Object.defineProperty(exports, "LokiDispatcher", { enumerable: true, get: function () { return LokiDispatcher_1.LokiDispatcher; } });
|
|
10
|
+
var SynchronousWorker_1 = require("./worker/SynchronousWorker");
|
|
11
|
+
Object.defineProperty(exports, "SynchronousWorker", { enumerable: true, get: function () { return SynchronousWorker_1.SynchronousWorker; } });
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LokiJS Dispatcher.
|
|
3
|
+
*
|
|
4
|
+
* Main-thread proxy that sends commands to a Web Worker (or SynchronousWorker)
|
|
5
|
+
* and matches responses to resolve/reject the corresponding Promises.
|
|
6
|
+
*
|
|
7
|
+
* All responses are assumed to arrive in FIFO order (the worker processes
|
|
8
|
+
* one command at a time). An ID-based sanity check catches any ordering bugs.
|
|
9
|
+
*/
|
|
10
|
+
import type { WorkerCommandType, WorkerInterface } from './types';
|
|
11
|
+
export declare class LokiDispatcher {
|
|
12
|
+
private _worker;
|
|
13
|
+
private _pendingCalls;
|
|
14
|
+
private _nextId;
|
|
15
|
+
constructor(worker: WorkerInterface);
|
|
16
|
+
/** Send a command to the worker and return a Promise for the result. */
|
|
17
|
+
call(type: WorkerCommandType, payload: unknown[]): Promise<unknown>;
|
|
18
|
+
/** Terminate the worker and reject all pending calls. */
|
|
19
|
+
terminate(): void;
|
|
20
|
+
private _onMessage;
|
|
21
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* LokiJS Dispatcher.
|
|
4
|
+
*
|
|
5
|
+
* Main-thread proxy that sends commands to a Web Worker (or SynchronousWorker)
|
|
6
|
+
* and matches responses to resolve/reject the corresponding Promises.
|
|
7
|
+
*
|
|
8
|
+
* All responses are assumed to arrive in FIFO order (the worker processes
|
|
9
|
+
* one command at a time). An ID-based sanity check catches any ordering bugs.
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.LokiDispatcher = void 0;
|
|
13
|
+
class LokiDispatcher {
|
|
14
|
+
_worker;
|
|
15
|
+
_pendingCalls = [];
|
|
16
|
+
_nextId = 1;
|
|
17
|
+
constructor(worker) {
|
|
18
|
+
this._worker = worker;
|
|
19
|
+
this._worker.onmessage = this._onMessage.bind(this);
|
|
20
|
+
}
|
|
21
|
+
/** Send a command to the worker and return a Promise for the result. */
|
|
22
|
+
call(type, payload) {
|
|
23
|
+
return new Promise((resolve, reject) => {
|
|
24
|
+
const id = this._nextId++;
|
|
25
|
+
this._pendingCalls.push({ id, resolve, reject });
|
|
26
|
+
const action = { id, type, payload };
|
|
27
|
+
this._worker.postMessage(action);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/** Terminate the worker and reject all pending calls. */
|
|
31
|
+
terminate() {
|
|
32
|
+
this._worker.terminate?.();
|
|
33
|
+
for (const pending of this._pendingCalls) {
|
|
34
|
+
pending.reject(new Error('Worker terminated'));
|
|
35
|
+
}
|
|
36
|
+
this._pendingCalls = [];
|
|
37
|
+
}
|
|
38
|
+
_onMessage(event) {
|
|
39
|
+
const response = event.data;
|
|
40
|
+
const pending = this._pendingCalls.shift();
|
|
41
|
+
if (!pending) {
|
|
42
|
+
console.error('[LokiDispatcher] Received response with no pending call');
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (pending.id !== response.id) {
|
|
46
|
+
console.error(`[LokiDispatcher] Response ID mismatch: expected ${pending.id}, got ${response.id}`);
|
|
47
|
+
pending.reject(new Error('Worker response ID mismatch'));
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if ('error' in response.result) {
|
|
51
|
+
const err = response.result.error;
|
|
52
|
+
const error = new Error(err.message);
|
|
53
|
+
if (err.stack)
|
|
54
|
+
error.stack = err.stack;
|
|
55
|
+
pending.reject(error);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
pending.resolve(response.result.value);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.LokiDispatcher = LokiDispatcher;
|
|
63
|
+
//# sourceMappingURL=LokiDispatcher.js.map
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LokiJS Executor.
|
|
3
|
+
*
|
|
4
|
+
* Contains all actual database operations using LokiJS.
|
|
5
|
+
* Runs either in the main thread (direct mode) or inside a Web Worker.
|
|
6
|
+
*/
|
|
7
|
+
import type { Migration } from '../../types';
|
|
8
|
+
import type { QueryDescriptor, SearchDescriptor, BatchOperation } from '../../../query/types';
|
|
9
|
+
import type { DatabaseSchema, RawRecord } from '../../../schema/types';
|
|
10
|
+
interface LokiCollection<T extends object = any> {
|
|
11
|
+
insert(doc: T): T;
|
|
12
|
+
findOne(query: object): T | null;
|
|
13
|
+
find(query?: object): T[];
|
|
14
|
+
update(doc: T): void;
|
|
15
|
+
remove(doc: T | T[]): void;
|
|
16
|
+
count(query?: object): number;
|
|
17
|
+
chain(): LokiResultset<T>;
|
|
18
|
+
clear(): void;
|
|
19
|
+
}
|
|
20
|
+
interface LokiResultset<T extends object = any> {
|
|
21
|
+
find(query: object): LokiResultset<T>;
|
|
22
|
+
where(fn: (doc: T) => boolean): LokiResultset<T>;
|
|
23
|
+
simplesort(field: string, options?: {
|
|
24
|
+
desc?: boolean;
|
|
25
|
+
}): LokiResultset<T>;
|
|
26
|
+
offset(n: number): LokiResultset<T>;
|
|
27
|
+
limit(n: number): LokiResultset<T>;
|
|
28
|
+
data(): T[];
|
|
29
|
+
count(): number;
|
|
30
|
+
}
|
|
31
|
+
interface LokiDb {
|
|
32
|
+
addCollection<T extends object>(name: string, options?: object): LokiCollection<T>;
|
|
33
|
+
getCollection<T extends object>(name: string): LokiCollection<T> | null;
|
|
34
|
+
removeCollection(name: string): void;
|
|
35
|
+
listCollections(): Array<{
|
|
36
|
+
name: string;
|
|
37
|
+
}>;
|
|
38
|
+
saveDatabase(callback?: (err: unknown) => void): void;
|
|
39
|
+
close(callback?: () => void): void;
|
|
40
|
+
}
|
|
41
|
+
export interface LokiExecutorConfig {
|
|
42
|
+
databaseName: string;
|
|
43
|
+
saveStrategy?: 'immediate' | 'auto';
|
|
44
|
+
autosaveInterval?: number;
|
|
45
|
+
/** Pre-constructed persistence adapter (direct mode only, not serializable). */
|
|
46
|
+
persistenceAdapter?: unknown;
|
|
47
|
+
/** Pre-constructed LokiJS instance (direct mode only, not serializable). */
|
|
48
|
+
lokiInstance?: LokiDb;
|
|
49
|
+
}
|
|
50
|
+
export declare class LokiExecutor {
|
|
51
|
+
private _db;
|
|
52
|
+
private _config;
|
|
53
|
+
private _schemaVersion;
|
|
54
|
+
private _initialized;
|
|
55
|
+
constructor(config: LokiExecutorConfig);
|
|
56
|
+
initialize(schema: DatabaseSchema): Promise<void>;
|
|
57
|
+
private _createLokiDb;
|
|
58
|
+
private _getCollection;
|
|
59
|
+
/**
|
|
60
|
+
* Persist to storage adapter.
|
|
61
|
+
* No-op when: no persistence configured, or saveStrategy is 'auto' (timer handles it).
|
|
62
|
+
*/
|
|
63
|
+
private _save;
|
|
64
|
+
private _doInsert;
|
|
65
|
+
private _doUpdate;
|
|
66
|
+
private _doMarkAsDeleted;
|
|
67
|
+
private _doDestroyPermanently;
|
|
68
|
+
find(query: QueryDescriptor): Promise<RawRecord[]>;
|
|
69
|
+
count(query: QueryDescriptor): Promise<number>;
|
|
70
|
+
findById(table: string, id: string): Promise<RawRecord | null>;
|
|
71
|
+
insert(table: string, raw: RawRecord): Promise<void>;
|
|
72
|
+
update(table: string, raw: RawRecord): Promise<void>;
|
|
73
|
+
markAsDeleted(table: string, id: string): Promise<void>;
|
|
74
|
+
destroyPermanently(table: string, id: string): Promise<void>;
|
|
75
|
+
batch(operations: BatchOperation[]): Promise<void>;
|
|
76
|
+
search(descriptor: SearchDescriptor): Promise<{
|
|
77
|
+
records: RawRecord[];
|
|
78
|
+
total: number;
|
|
79
|
+
}>;
|
|
80
|
+
getLocalChanges(tables: string[]): Promise<Record<string, {
|
|
81
|
+
created: RawRecord[];
|
|
82
|
+
updated: RawRecord[];
|
|
83
|
+
deleted: string[];
|
|
84
|
+
}>>;
|
|
85
|
+
applyRemoteChanges(changes: Record<string, {
|
|
86
|
+
created: RawRecord[];
|
|
87
|
+
updated: RawRecord[];
|
|
88
|
+
deleted: string[];
|
|
89
|
+
}>): Promise<void>;
|
|
90
|
+
markAsSynced(table: string, ids: string[]): Promise<void>;
|
|
91
|
+
getSchemaVersion(): Promise<number>;
|
|
92
|
+
migrate(migrations: Migration[]): Promise<void>;
|
|
93
|
+
reset(): Promise<void>;
|
|
94
|
+
close(): Promise<void>;
|
|
95
|
+
}
|
|
96
|
+
export {};
|