@quereus/plugin-nativescript-sqlite 0.1.1
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/README.md +180 -0
- package/dist/src/index.d.ts +38 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +38 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/plugin.d.ts +54 -0
- package/dist/src/plugin.d.ts.map +1 -0
- package/dist/src/plugin.js +50 -0
- package/dist/src/plugin.js.map +1 -0
- package/dist/src/provider.d.ts +54 -0
- package/dist/src/provider.d.ts.map +1 -0
- package/dist/src/provider.js +80 -0
- package/dist/src/provider.js.map +1 -0
- package/dist/src/store.d.ts +70 -0
- package/dist/src/store.d.ts.map +1 -0
- package/dist/src/store.js +200 -0
- package/dist/src/store.js.map +1 -0
- package/package.json +94 -0
package/README.md
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
# @quereus/plugin-nativescript-sqlite
|
|
2
|
+
|
|
3
|
+
SQLite storage plugin for Quereus on NativeScript. Provides persistent storage for iOS and Android mobile apps using the [`@quereus/store`](../quereus-store/) module.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Native SQLite**: Uses the device's built-in SQLite via `@nativescript-community/sqlite`
|
|
8
|
+
- **Order-preserving keys**: BLOB keys with `memcmp()` comparison ensure correct lexicographic byte ordering
|
|
9
|
+
- **Single database file**: All stores share one SQLite database (separate tables)
|
|
10
|
+
- **ACID transactions**: SQLite transactions for atomic batch writes
|
|
11
|
+
- **WITHOUT ROWID**: Optimized key-value table structure
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @quereus/plugin-nativescript-sqlite @quereus/store @nativescript-community/sqlite
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Or with NativeScript CLI:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
ns plugin add @quereus/plugin-nativescript-sqlite
|
|
23
|
+
ns plugin add @nativescript-community/sqlite
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Quick Start
|
|
27
|
+
|
|
28
|
+
### With registerPlugin (Recommended)
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
import { openOrCreate } from '@nativescript-community/sqlite';
|
|
32
|
+
import { Database, registerPlugin } from '@quereus/quereus';
|
|
33
|
+
import sqlitePlugin from '@quereus/plugin-nativescript-sqlite/plugin';
|
|
34
|
+
|
|
35
|
+
// Open or create the SQLite database
|
|
36
|
+
const sqliteDb = openOrCreate('quereus.db');
|
|
37
|
+
|
|
38
|
+
// Create Quereus database and register the plugin
|
|
39
|
+
const db = new Database();
|
|
40
|
+
await registerPlugin(db, sqlitePlugin, { db: sqliteDb });
|
|
41
|
+
|
|
42
|
+
// Create tables using the 'store' module
|
|
43
|
+
await db.exec(`
|
|
44
|
+
create table users (id integer primary key, name text)
|
|
45
|
+
using store
|
|
46
|
+
`);
|
|
47
|
+
|
|
48
|
+
// Use standard SQL
|
|
49
|
+
await db.exec(`insert into users values (1, 'Alice')`);
|
|
50
|
+
const users = await db.all(`select * from users`);
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Direct Usage with Provider
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
import { openOrCreate } from '@nativescript-community/sqlite';
|
|
57
|
+
import { Database } from '@quereus/quereus';
|
|
58
|
+
import { createSQLiteProvider } from '@quereus/plugin-nativescript-sqlite';
|
|
59
|
+
import { StoreModule } from '@quereus/store';
|
|
60
|
+
|
|
61
|
+
const sqliteDb = openOrCreate('quereus.db');
|
|
62
|
+
const provider = createSQLiteProvider({ db: sqliteDb });
|
|
63
|
+
const storeModule = new StoreModule(provider);
|
|
64
|
+
|
|
65
|
+
const db = new Database();
|
|
66
|
+
db.registerVtabModule('store', storeModule);
|
|
67
|
+
|
|
68
|
+
await db.exec(`
|
|
69
|
+
create table users (id integer primary key, name text)
|
|
70
|
+
using store
|
|
71
|
+
`);
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## API
|
|
75
|
+
|
|
76
|
+
### SQLiteStore
|
|
77
|
+
|
|
78
|
+
Low-level KVStore implementation backed by a SQLite table:
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
import { openOrCreate } from '@nativescript-community/sqlite';
|
|
82
|
+
import { SQLiteStore } from '@quereus/plugin-nativescript-sqlite';
|
|
83
|
+
|
|
84
|
+
const sqliteDb = openOrCreate('myapp.db');
|
|
85
|
+
const store = SQLiteStore.create(sqliteDb, 'my_kv_table');
|
|
86
|
+
|
|
87
|
+
// Key-value operations (keys and values are Uint8Array)
|
|
88
|
+
await store.put(key, value);
|
|
89
|
+
const data = await store.get(key);
|
|
90
|
+
await store.delete(key);
|
|
91
|
+
|
|
92
|
+
// Range iteration
|
|
93
|
+
for await (const { key, value } of store.iterate({ gte: startKey, lt: endKey })) {
|
|
94
|
+
console.log(key, value);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Batch writes (atomic)
|
|
98
|
+
const batch = store.batch();
|
|
99
|
+
batch.put(key1, value1);
|
|
100
|
+
batch.put(key2, value2);
|
|
101
|
+
batch.delete(key3);
|
|
102
|
+
await batch.write();
|
|
103
|
+
|
|
104
|
+
await store.close();
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### SQLiteProvider
|
|
108
|
+
|
|
109
|
+
Factory for managing multiple stores in a single SQLite database:
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
import { openOrCreate } from '@nativescript-community/sqlite';
|
|
113
|
+
import { createSQLiteProvider } from '@quereus/plugin-nativescript-sqlite';
|
|
114
|
+
|
|
115
|
+
const sqliteDb = openOrCreate('quereus.db');
|
|
116
|
+
const provider = createSQLiteProvider({ db: sqliteDb });
|
|
117
|
+
|
|
118
|
+
// Each store gets its own table: quereus_main_users, quereus_main_orders, etc.
|
|
119
|
+
const userStore = await provider.getStore('main', 'users');
|
|
120
|
+
const orderStore = await provider.getStore('main', 'orders');
|
|
121
|
+
const catalogStore = await provider.getCatalogStore();
|
|
122
|
+
|
|
123
|
+
await provider.closeStore('main', 'users');
|
|
124
|
+
await provider.closeAll(); // Also closes the SQLite database
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Configuration
|
|
128
|
+
|
|
129
|
+
### Plugin Settings
|
|
130
|
+
|
|
131
|
+
| Setting | Type | Default | Description |
|
|
132
|
+
|---------|------|---------|-------------|
|
|
133
|
+
| `db` | SQLiteDatabase | **required** | SQLite database from `openOrCreate()` |
|
|
134
|
+
| `tablePrefix` | string | `'quereus_'` | Prefix for all table names |
|
|
135
|
+
| `moduleName` | string | `'store'` | Virtual table module name for `USING` clause |
|
|
136
|
+
|
|
137
|
+
### SQLiteStore Options
|
|
138
|
+
|
|
139
|
+
| Option | Type | Default | Description |
|
|
140
|
+
|--------|------|---------|-------------|
|
|
141
|
+
| `db` | SQLiteDatabase | **required** | The SQLite database instance |
|
|
142
|
+
| `tableName` | string | `'kv'` | Table name for this store |
|
|
143
|
+
|
|
144
|
+
## How It Works
|
|
145
|
+
|
|
146
|
+
### Key Storage
|
|
147
|
+
|
|
148
|
+
Keys and values are stored as BLOBs (binary). SQLite compares BLOBs using `memcmp()`, which provides correct lexicographic byte ordering - exactly what's needed for range scans.
|
|
149
|
+
|
|
150
|
+
### Table Structure
|
|
151
|
+
|
|
152
|
+
Each store creates a table with this schema:
|
|
153
|
+
|
|
154
|
+
```sql
|
|
155
|
+
create table quereus_main_users (
|
|
156
|
+
key blob primary key,
|
|
157
|
+
value blob
|
|
158
|
+
) without rowid
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
The `WITHOUT ROWID` optimization is ideal for key-value workloads where the key is the primary lookup.
|
|
162
|
+
|
|
163
|
+
## Platform Support
|
|
164
|
+
|
|
165
|
+
| Platform | Status |
|
|
166
|
+
|----------|--------|
|
|
167
|
+
| iOS | ✅ Supported |
|
|
168
|
+
| Android | ✅ Supported |
|
|
169
|
+
| NativeScript 8+ | ✅ Supported |
|
|
170
|
+
|
|
171
|
+
## Related Packages
|
|
172
|
+
|
|
173
|
+
- [`@quereus/store`](../quereus-store/) - Core storage module (StoreModule, StoreTable)
|
|
174
|
+
- [`@quereus/plugin-leveldb`](../quereus-plugin-leveldb/) - LevelDB plugin for Node.js
|
|
175
|
+
- [`@quereus/plugin-indexeddb`](../quereus-plugin-indexeddb/) - IndexedDB plugin for browsers
|
|
176
|
+
|
|
177
|
+
## License
|
|
178
|
+
|
|
179
|
+
MIT
|
|
180
|
+
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NativeScript SQLite storage plugin for Quereus.
|
|
3
|
+
*
|
|
4
|
+
* Provides SQLite-based persistent storage for NativeScript mobile environments
|
|
5
|
+
* (iOS and Android).
|
|
6
|
+
*
|
|
7
|
+
* @example Using as a plugin (recommended)
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { openOrCreate } from '@nativescript-community/sqlite';
|
|
10
|
+
* import { Database, registerPlugin } from '@quereus/quereus';
|
|
11
|
+
* import sqlitePlugin from '@quereus/plugin-nativescript-sqlite/plugin';
|
|
12
|
+
*
|
|
13
|
+
* const sqliteDb = openOrCreate('quereus.db');
|
|
14
|
+
* const db = new Database();
|
|
15
|
+
* await registerPlugin(db, sqlitePlugin, { db: sqliteDb });
|
|
16
|
+
*
|
|
17
|
+
* await db.exec(`
|
|
18
|
+
* create table users (id integer primary key, name text)
|
|
19
|
+
* using store
|
|
20
|
+
* `);
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @example Using the provider directly
|
|
24
|
+
* ```typescript
|
|
25
|
+
* import { openOrCreate } from '@nativescript-community/sqlite';
|
|
26
|
+
* import { createSQLiteProvider } from '@quereus/plugin-nativescript-sqlite';
|
|
27
|
+
* import { StoreModule } from '@quereus/store';
|
|
28
|
+
*
|
|
29
|
+
* const sqliteDb = openOrCreate('quereus.db');
|
|
30
|
+
* const provider = createSQLiteProvider({ db: sqliteDb });
|
|
31
|
+
* const storeModule = new StoreModule(provider);
|
|
32
|
+
* db.registerVtabModule('store', storeModule);
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export { SQLiteStore, type SQLiteDatabase, type SQLiteStoreOptions } from './store.js';
|
|
36
|
+
export { SQLiteProvider, createSQLiteProvider, type SQLiteProviderOptions } from './provider.js';
|
|
37
|
+
export { default as plugin, type SQLitePluginConfig } from './plugin.js';
|
|
38
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAAE,WAAW,EAAE,KAAK,cAAc,EAAE,KAAK,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACvF,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,KAAK,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACjG,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,KAAK,kBAAkB,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NativeScript SQLite storage plugin for Quereus.
|
|
3
|
+
*
|
|
4
|
+
* Provides SQLite-based persistent storage for NativeScript mobile environments
|
|
5
|
+
* (iOS and Android).
|
|
6
|
+
*
|
|
7
|
+
* @example Using as a plugin (recommended)
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { openOrCreate } from '@nativescript-community/sqlite';
|
|
10
|
+
* import { Database, registerPlugin } from '@quereus/quereus';
|
|
11
|
+
* import sqlitePlugin from '@quereus/plugin-nativescript-sqlite/plugin';
|
|
12
|
+
*
|
|
13
|
+
* const sqliteDb = openOrCreate('quereus.db');
|
|
14
|
+
* const db = new Database();
|
|
15
|
+
* await registerPlugin(db, sqlitePlugin, { db: sqliteDb });
|
|
16
|
+
*
|
|
17
|
+
* await db.exec(`
|
|
18
|
+
* create table users (id integer primary key, name text)
|
|
19
|
+
* using store
|
|
20
|
+
* `);
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @example Using the provider directly
|
|
24
|
+
* ```typescript
|
|
25
|
+
* import { openOrCreate } from '@nativescript-community/sqlite';
|
|
26
|
+
* import { createSQLiteProvider } from '@quereus/plugin-nativescript-sqlite';
|
|
27
|
+
* import { StoreModule } from '@quereus/store';
|
|
28
|
+
*
|
|
29
|
+
* const sqliteDb = openOrCreate('quereus.db');
|
|
30
|
+
* const provider = createSQLiteProvider({ db: sqliteDb });
|
|
31
|
+
* const storeModule = new StoreModule(provider);
|
|
32
|
+
* db.registerVtabModule('store', storeModule);
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export { SQLiteStore } from './store.js';
|
|
36
|
+
export { SQLiteProvider, createSQLiteProvider } from './provider.js';
|
|
37
|
+
export { default as plugin } from './plugin.js';
|
|
38
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAAE,WAAW,EAAgD,MAAM,YAAY,CAAC;AACvF,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAA8B,MAAM,eAAe,CAAC;AACjG,OAAO,EAAE,OAAO,IAAI,MAAM,EAA2B,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NativeScript SQLite plugin for Quereus.
|
|
3
|
+
*
|
|
4
|
+
* Registers a StoreModule backed by SQLite for NativeScript mobile environments.
|
|
5
|
+
*/
|
|
6
|
+
import type { Database, SqlValue } from '@quereus/quereus';
|
|
7
|
+
import { StoreModule } from '@quereus/store';
|
|
8
|
+
import type { SQLiteDatabase } from './store.js';
|
|
9
|
+
/**
|
|
10
|
+
* Plugin configuration options.
|
|
11
|
+
*/
|
|
12
|
+
export interface SQLitePluginConfig {
|
|
13
|
+
/**
|
|
14
|
+
* The SQLite database instance.
|
|
15
|
+
* Obtain this from @nativescript-community/sqlite's openOrCreate().
|
|
16
|
+
*/
|
|
17
|
+
db: SQLiteDatabase;
|
|
18
|
+
/**
|
|
19
|
+
* Prefix for table names to avoid collisions.
|
|
20
|
+
* @default 'quereus_'
|
|
21
|
+
*/
|
|
22
|
+
tablePrefix?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Module name to register. Tables are created with `USING <moduleName>`.
|
|
25
|
+
* @default 'store'
|
|
26
|
+
*/
|
|
27
|
+
moduleName?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Register the NativeScript SQLite plugin with a database.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* import { openOrCreate } from '@nativescript-community/sqlite';
|
|
35
|
+
* import { Database, registerPlugin } from '@quereus/quereus';
|
|
36
|
+
* import sqlitePlugin from '@quereus/plugin-nativescript-sqlite/plugin';
|
|
37
|
+
*
|
|
38
|
+
* const sqliteDb = openOrCreate('quereus.db');
|
|
39
|
+
* const db = new Database();
|
|
40
|
+
* await registerPlugin(db, sqlitePlugin, { db: sqliteDb });
|
|
41
|
+
*
|
|
42
|
+
* await db.exec(`
|
|
43
|
+
* create table users (id integer primary key, name text)
|
|
44
|
+
* using store
|
|
45
|
+
* `);
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export default function register(_db: Database, config?: Record<string, SqlValue>): {
|
|
49
|
+
vtables: {
|
|
50
|
+
name: string;
|
|
51
|
+
module: StoreModule;
|
|
52
|
+
}[];
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,EAAE,EAAE,cAAc,CAAC;IAEnB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAC9B,GAAG,EAAE,QAAQ,EACb,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAM;;;;;EA6BtC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NativeScript SQLite plugin for Quereus.
|
|
3
|
+
*
|
|
4
|
+
* Registers a StoreModule backed by SQLite for NativeScript mobile environments.
|
|
5
|
+
*/
|
|
6
|
+
import { StoreModule } from '@quereus/store';
|
|
7
|
+
import { SQLiteProvider } from './provider.js';
|
|
8
|
+
/**
|
|
9
|
+
* Register the NativeScript SQLite plugin with a database.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { openOrCreate } from '@nativescript-community/sqlite';
|
|
14
|
+
* import { Database, registerPlugin } from '@quereus/quereus';
|
|
15
|
+
* import sqlitePlugin from '@quereus/plugin-nativescript-sqlite/plugin';
|
|
16
|
+
*
|
|
17
|
+
* const sqliteDb = openOrCreate('quereus.db');
|
|
18
|
+
* const db = new Database();
|
|
19
|
+
* await registerPlugin(db, sqlitePlugin, { db: sqliteDb });
|
|
20
|
+
*
|
|
21
|
+
* await db.exec(`
|
|
22
|
+
* create table users (id integer primary key, name text)
|
|
23
|
+
* using store
|
|
24
|
+
* `);
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export default function register(_db, config = {}) {
|
|
28
|
+
// The SQLite database must be provided
|
|
29
|
+
const sqliteDb = config.db;
|
|
30
|
+
if (!sqliteDb) {
|
|
31
|
+
throw new Error('@quereus/plugin-nativescript-sqlite requires a "db" option with an open SQLite database. ' +
|
|
32
|
+
'Use openOrCreate() from @nativescript-community/sqlite to create one.');
|
|
33
|
+
}
|
|
34
|
+
const tablePrefix = config.tablePrefix ?? 'quereus_';
|
|
35
|
+
const moduleName = config.moduleName ?? 'store';
|
|
36
|
+
const provider = new SQLiteProvider({
|
|
37
|
+
db: sqliteDb,
|
|
38
|
+
tablePrefix,
|
|
39
|
+
});
|
|
40
|
+
const storeModule = new StoreModule(provider);
|
|
41
|
+
return {
|
|
42
|
+
vtables: [
|
|
43
|
+
{
|
|
44
|
+
name: moduleName,
|
|
45
|
+
module: storeModule,
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AA0B/C;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAC9B,GAAa,EACb,SAAmC,EAAE;IAErC,uCAAuC;IACvC,MAAM,QAAQ,GAAG,MAAM,CAAC,EAA+B,CAAC;IACxD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CACb,2FAA2F;YAC3F,uEAAuE,CACxE,CAAC;IACJ,CAAC;IAED,MAAM,WAAW,GAAI,MAAM,CAAC,WAAsB,IAAI,UAAU,CAAC;IACjE,MAAM,UAAU,GAAI,MAAM,CAAC,UAAqB,IAAI,OAAO,CAAC;IAE5D,MAAM,QAAQ,GAAG,IAAI,cAAc,CAAC;QAClC,EAAE,EAAE,QAAQ;QACZ,WAAW;KACZ,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,QAAQ,CAAC,CAAC;IAE9C,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,UAAU;gBAChB,MAAM,EAAE,WAAW;aACpB;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SQLite KVStore provider implementation for NativeScript.
|
|
3
|
+
*
|
|
4
|
+
* Manages SQLite-backed KV stores for the StoreModule.
|
|
5
|
+
* Uses a single SQLite database with multiple tables (one per logical store).
|
|
6
|
+
*/
|
|
7
|
+
import type { KVStore, KVStoreProvider } from '@quereus/store';
|
|
8
|
+
import { type SQLiteDatabase } from './store.js';
|
|
9
|
+
/**
|
|
10
|
+
* Options for creating a SQLite provider.
|
|
11
|
+
*/
|
|
12
|
+
export interface SQLiteProviderOptions {
|
|
13
|
+
/**
|
|
14
|
+
* The SQLite database instance.
|
|
15
|
+
* Obtain this from @nativescript-community/sqlite's openOrCreate().
|
|
16
|
+
*/
|
|
17
|
+
db: SQLiteDatabase;
|
|
18
|
+
/**
|
|
19
|
+
* Prefix for table names to avoid collisions.
|
|
20
|
+
* @default 'quereus_'
|
|
21
|
+
*/
|
|
22
|
+
tablePrefix?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* SQLite implementation of KVStoreProvider for NativeScript.
|
|
26
|
+
*
|
|
27
|
+
* Creates separate tables for each logical store within a single SQLite database.
|
|
28
|
+
* This is more efficient than multiple database files on mobile.
|
|
29
|
+
*/
|
|
30
|
+
export declare class SQLiteProvider implements KVStoreProvider {
|
|
31
|
+
private db;
|
|
32
|
+
private tablePrefix;
|
|
33
|
+
private stores;
|
|
34
|
+
private catalogStore;
|
|
35
|
+
constructor(options: SQLiteProviderOptions);
|
|
36
|
+
/**
|
|
37
|
+
* Get the table name for a store.
|
|
38
|
+
* Sanitizes schema/table names to valid SQLite identifiers.
|
|
39
|
+
*/
|
|
40
|
+
private getTableName;
|
|
41
|
+
/**
|
|
42
|
+
* Get the key for the store cache.
|
|
43
|
+
*/
|
|
44
|
+
private getStoreKey;
|
|
45
|
+
getStore(schemaName: string, tableName: string, _options?: Record<string, unknown>): Promise<KVStore>;
|
|
46
|
+
getCatalogStore(): Promise<KVStore>;
|
|
47
|
+
closeStore(schemaName: string, tableName: string): Promise<void>;
|
|
48
|
+
closeAll(): Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Create a SQLite provider with the given options.
|
|
52
|
+
*/
|
|
53
|
+
export declare function createSQLiteProvider(options: SQLiteProviderOptions): SQLiteProvider;
|
|
54
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAe,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,EAAE,EAAE,cAAc,CAAC;IAEnB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;GAKG;AACH,qBAAa,cAAe,YAAW,eAAe;IACpD,OAAO,CAAC,EAAE,CAAiB;IAC3B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,MAAM,CAAkC;IAChD,OAAO,CAAC,YAAY,CAA4B;gBAEpC,OAAO,EAAE,qBAAqB;IAK1C;;;OAGG;IACH,OAAO,CAAC,YAAY;IAKpB;;OAEG;IACH,OAAO,CAAC,WAAW;IAIb,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAarG,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC;IAOnC,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAShE,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAchC;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG,cAAc,CAEnF"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SQLite KVStore provider implementation for NativeScript.
|
|
3
|
+
*
|
|
4
|
+
* Manages SQLite-backed KV stores for the StoreModule.
|
|
5
|
+
* Uses a single SQLite database with multiple tables (one per logical store).
|
|
6
|
+
*/
|
|
7
|
+
import { SQLiteStore } from './store.js';
|
|
8
|
+
/**
|
|
9
|
+
* SQLite implementation of KVStoreProvider for NativeScript.
|
|
10
|
+
*
|
|
11
|
+
* Creates separate tables for each logical store within a single SQLite database.
|
|
12
|
+
* This is more efficient than multiple database files on mobile.
|
|
13
|
+
*/
|
|
14
|
+
export class SQLiteProvider {
|
|
15
|
+
db;
|
|
16
|
+
tablePrefix;
|
|
17
|
+
stores = new Map();
|
|
18
|
+
catalogStore = null;
|
|
19
|
+
constructor(options) {
|
|
20
|
+
this.db = options.db;
|
|
21
|
+
this.tablePrefix = options.tablePrefix ?? 'quereus_';
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Get the table name for a store.
|
|
25
|
+
* Sanitizes schema/table names to valid SQLite identifiers.
|
|
26
|
+
*/
|
|
27
|
+
getTableName(schemaName, tableName) {
|
|
28
|
+
const sanitized = `${schemaName}_${tableName}`.replace(/[^a-zA-Z0-9_]/g, '_');
|
|
29
|
+
return `${this.tablePrefix}${sanitized}`;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Get the key for the store cache.
|
|
33
|
+
*/
|
|
34
|
+
getStoreKey(schemaName, tableName) {
|
|
35
|
+
return `${schemaName}.${tableName}`.toLowerCase();
|
|
36
|
+
}
|
|
37
|
+
async getStore(schemaName, tableName, _options) {
|
|
38
|
+
const key = this.getStoreKey(schemaName, tableName);
|
|
39
|
+
let store = this.stores.get(key);
|
|
40
|
+
if (!store) {
|
|
41
|
+
const sqliteTableName = this.getTableName(schemaName, tableName);
|
|
42
|
+
store = SQLiteStore.create(this.db, sqliteTableName);
|
|
43
|
+
this.stores.set(key, store);
|
|
44
|
+
}
|
|
45
|
+
return store;
|
|
46
|
+
}
|
|
47
|
+
async getCatalogStore() {
|
|
48
|
+
if (!this.catalogStore) {
|
|
49
|
+
this.catalogStore = SQLiteStore.create(this.db, `${this.tablePrefix}__catalog__`);
|
|
50
|
+
}
|
|
51
|
+
return this.catalogStore;
|
|
52
|
+
}
|
|
53
|
+
async closeStore(schemaName, tableName) {
|
|
54
|
+
const key = this.getStoreKey(schemaName, tableName);
|
|
55
|
+
const store = this.stores.get(key);
|
|
56
|
+
if (store) {
|
|
57
|
+
await store.close();
|
|
58
|
+
this.stores.delete(key);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
async closeAll() {
|
|
62
|
+
for (const store of this.stores.values()) {
|
|
63
|
+
await store.close();
|
|
64
|
+
}
|
|
65
|
+
this.stores.clear();
|
|
66
|
+
if (this.catalogStore) {
|
|
67
|
+
await this.catalogStore.close();
|
|
68
|
+
this.catalogStore = null;
|
|
69
|
+
}
|
|
70
|
+
// Close the underlying database
|
|
71
|
+
this.db.close();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Create a SQLite provider with the given options.
|
|
76
|
+
*/
|
|
77
|
+
export function createSQLiteProvider(options) {
|
|
78
|
+
return new SQLiteProvider(options);
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,WAAW,EAAuB,MAAM,YAAY,CAAC;AAmB9D;;;;;GAKG;AACH,MAAM,OAAO,cAAc;IACjB,EAAE,CAAiB;IACnB,WAAW,CAAS;IACpB,MAAM,GAAG,IAAI,GAAG,EAAuB,CAAC;IACxC,YAAY,GAAuB,IAAI,CAAC;IAEhD,YAAY,OAA8B;QACxC,IAAI,CAAC,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,UAAU,CAAC;IACvD,CAAC;IAED;;;OAGG;IACK,YAAY,CAAC,UAAkB,EAAE,SAAiB;QACxD,MAAM,SAAS,GAAG,GAAG,UAAU,IAAI,SAAS,EAAE,CAAC,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC;QAC9E,OAAO,GAAG,IAAI,CAAC,WAAW,GAAG,SAAS,EAAE,CAAC;IAC3C,CAAC;IAED;;OAEG;IACK,WAAW,CAAC,UAAkB,EAAE,SAAiB;QACvD,OAAO,GAAG,UAAU,IAAI,SAAS,EAAE,CAAC,WAAW,EAAE,CAAC;IACpD,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,UAAkB,EAAE,SAAiB,EAAE,QAAkC;QACtF,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;QACpD,IAAI,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAEjC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,eAAe,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,SAAS,CAAC,C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CAAC;IAClB,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAA8B;IACjE,OAAO,IAAI,cAAc,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SQLite-based KVStore implementation for NativeScript.
|
|
3
|
+
*
|
|
4
|
+
* Uses @nativescript-community/sqlite for SQLite bindings on iOS/Android.
|
|
5
|
+
* Keys and values are stored as BLOBs for correct lexicographic ordering.
|
|
6
|
+
*/
|
|
7
|
+
import type { KVStore, KVEntry, WriteBatch, IterateOptions } from '@quereus/store';
|
|
8
|
+
/**
|
|
9
|
+
* Type definition for @nativescript-community/sqlite database.
|
|
10
|
+
* We use a minimal interface to avoid hard dependency on the package types.
|
|
11
|
+
*/
|
|
12
|
+
export interface SQLiteDatabase {
|
|
13
|
+
execute(sql: string, params?: unknown[]): void;
|
|
14
|
+
select(sql: string, params?: unknown[]): unknown[];
|
|
15
|
+
transaction<T>(fn: (cancelTransaction: () => void) => T): T;
|
|
16
|
+
close(): void;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Options for opening a SQLite store.
|
|
20
|
+
*/
|
|
21
|
+
export interface SQLiteStoreOptions {
|
|
22
|
+
/** The SQLite database instance. */
|
|
23
|
+
db: SQLiteDatabase;
|
|
24
|
+
/** Table name for this KV store. Default: 'kv' */
|
|
25
|
+
tableName?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* SQLite implementation of KVStore for NativeScript.
|
|
29
|
+
*
|
|
30
|
+
* Keys and values are stored as BLOBs. SQLite compares BLOBs using memcmp(),
|
|
31
|
+
* which provides correct lexicographic byte ordering for range scans.
|
|
32
|
+
*/
|
|
33
|
+
export declare class SQLiteStore implements KVStore {
|
|
34
|
+
private db;
|
|
35
|
+
private tableName;
|
|
36
|
+
private closed;
|
|
37
|
+
private readonly sqlGet;
|
|
38
|
+
private readonly sqlPut;
|
|
39
|
+
private readonly sqlDelete;
|
|
40
|
+
private readonly sqlHas;
|
|
41
|
+
constructor(options: SQLiteStoreOptions);
|
|
42
|
+
/**
|
|
43
|
+
* Create a SQLiteStore with a new table in the given database.
|
|
44
|
+
*/
|
|
45
|
+
static create(db: SQLiteDatabase, tableName?: string): SQLiteStore;
|
|
46
|
+
private ensureTable;
|
|
47
|
+
get(key: Uint8Array): Promise<Uint8Array | undefined>;
|
|
48
|
+
put(key: Uint8Array, value: Uint8Array): Promise<void>;
|
|
49
|
+
delete(key: Uint8Array): Promise<void>;
|
|
50
|
+
has(key: Uint8Array): Promise<boolean>;
|
|
51
|
+
iterate(options?: IterateOptions): AsyncIterable<KVEntry>;
|
|
52
|
+
private buildIterateQuery;
|
|
53
|
+
batch(): WriteBatch;
|
|
54
|
+
close(): Promise<void>;
|
|
55
|
+
approximateCount(options?: IterateOptions): Promise<number>;
|
|
56
|
+
private checkOpen;
|
|
57
|
+
/**
|
|
58
|
+
* Execute a batch of operations atomically.
|
|
59
|
+
* Called by SQLiteWriteBatch.
|
|
60
|
+
*/
|
|
61
|
+
executeBatch(ops: Array<{
|
|
62
|
+
type: 'put';
|
|
63
|
+
key: Uint8Array;
|
|
64
|
+
value: Uint8Array;
|
|
65
|
+
} | {
|
|
66
|
+
type: 'delete';
|
|
67
|
+
key: Uint8Array;
|
|
68
|
+
}>): void;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/store.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEnF;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,GAAG,IAAI,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OAAO,CAAC,iBAAiB;IAiCzB,KAAK,IAAI,UAAU;IAKb,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAKtB,gBAAgB,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC;IAgBjE,OAAO,CAAC,SAAS;IAMjB;;;OAGG;IACH,YAAY,CAAC,GAAG,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,KAAK,CAAC;QAAC,GAAG,EAAE,UAAU,CAAC;QAAC,KAAK,EAAE,UAAU,CAAA;KAAE,GAAG;QAAE,IAAI,EAAE,QAAQ,CAAC;QAAC,GAAG,EAAE,UAAU,CAAA;KAAE,CAAC,GAAG,IAAI;CAa1H"}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SQLite-based KVStore implementation for NativeScript.
|
|
3
|
+
*
|
|
4
|
+
* Uses @nativescript-community/sqlite for SQLite bindings on iOS/Android.
|
|
5
|
+
* Keys and values are stored as BLOBs for correct lexicographic ordering.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* SQLite implementation of KVStore for NativeScript.
|
|
9
|
+
*
|
|
10
|
+
* Keys and values are stored as BLOBs. SQLite compares BLOBs using memcmp(),
|
|
11
|
+
* which provides correct lexicographic byte ordering for range scans.
|
|
12
|
+
*/
|
|
13
|
+
export class SQLiteStore {
|
|
14
|
+
db;
|
|
15
|
+
tableName;
|
|
16
|
+
closed = false;
|
|
17
|
+
// Prepared SQL statements (built once)
|
|
18
|
+
sqlGet;
|
|
19
|
+
sqlPut;
|
|
20
|
+
sqlDelete;
|
|
21
|
+
sqlHas;
|
|
22
|
+
constructor(options) {
|
|
23
|
+
this.db = options.db;
|
|
24
|
+
this.tableName = options.tableName ?? 'kv';
|
|
25
|
+
// Pre-build SQL statements
|
|
26
|
+
this.sqlGet = `select value from ${this.tableName} where key = ?`;
|
|
27
|
+
this.sqlPut = `insert or replace into ${this.tableName} (key, value) values (?, ?)`;
|
|
28
|
+
this.sqlDelete = `delete from ${this.tableName} where key = ?`;
|
|
29
|
+
this.sqlHas = `select 1 from ${this.tableName} where key = ? limit 1`;
|
|
30
|
+
// Create table if it doesn't exist
|
|
31
|
+
this.ensureTable();
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Create a SQLiteStore with a new table in the given database.
|
|
35
|
+
*/
|
|
36
|
+
static create(db, tableName = 'kv') {
|
|
37
|
+
return new SQLiteStore({ db, tableName });
|
|
38
|
+
}
|
|
39
|
+
ensureTable() {
|
|
40
|
+
// Use WITHOUT ROWID for better key-value performance
|
|
41
|
+
// Keys are BLOBs - SQLite uses memcmp() for correct byte ordering
|
|
42
|
+
this.db.execute(`
|
|
43
|
+
create table if not exists ${this.tableName} (
|
|
44
|
+
key blob primary key,
|
|
45
|
+
value blob
|
|
46
|
+
) without rowid
|
|
47
|
+
`);
|
|
48
|
+
}
|
|
49
|
+
async get(key) {
|
|
50
|
+
this.checkOpen();
|
|
51
|
+
const rows = this.db.select(this.sqlGet, [toArrayBuffer(key)]);
|
|
52
|
+
if (rows.length === 0 || rows[0].value === null) {
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
return toUint8Array(rows[0].value);
|
|
56
|
+
}
|
|
57
|
+
async put(key, value) {
|
|
58
|
+
this.checkOpen();
|
|
59
|
+
this.db.execute(this.sqlPut, [toArrayBuffer(key), toArrayBuffer(value)]);
|
|
60
|
+
}
|
|
61
|
+
async delete(key) {
|
|
62
|
+
this.checkOpen();
|
|
63
|
+
this.db.execute(this.sqlDelete, [toArrayBuffer(key)]);
|
|
64
|
+
}
|
|
65
|
+
async has(key) {
|
|
66
|
+
this.checkOpen();
|
|
67
|
+
const rows = this.db.select(this.sqlHas, [toArrayBuffer(key)]);
|
|
68
|
+
return rows.length > 0;
|
|
69
|
+
}
|
|
70
|
+
async *iterate(options) {
|
|
71
|
+
this.checkOpen();
|
|
72
|
+
const { sql, params } = this.buildIterateQuery(options);
|
|
73
|
+
const rows = this.db.select(sql, params);
|
|
74
|
+
for (const row of rows) {
|
|
75
|
+
yield {
|
|
76
|
+
key: toUint8Array(row.key),
|
|
77
|
+
value: toUint8Array(row.value),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
buildIterateQuery(options) {
|
|
82
|
+
const conditions = [];
|
|
83
|
+
const params = [];
|
|
84
|
+
if (options?.gte) {
|
|
85
|
+
conditions.push('key >= ?');
|
|
86
|
+
params.push(toArrayBuffer(options.gte));
|
|
87
|
+
}
|
|
88
|
+
if (options?.gt) {
|
|
89
|
+
conditions.push('key > ?');
|
|
90
|
+
params.push(toArrayBuffer(options.gt));
|
|
91
|
+
}
|
|
92
|
+
if (options?.lte) {
|
|
93
|
+
conditions.push('key <= ?');
|
|
94
|
+
params.push(toArrayBuffer(options.lte));
|
|
95
|
+
}
|
|
96
|
+
if (options?.lt) {
|
|
97
|
+
conditions.push('key < ?');
|
|
98
|
+
params.push(toArrayBuffer(options.lt));
|
|
99
|
+
}
|
|
100
|
+
let sql = `select key, value from ${this.tableName}`;
|
|
101
|
+
if (conditions.length > 0) {
|
|
102
|
+
sql += ` where ${conditions.join(' and ')}`;
|
|
103
|
+
}
|
|
104
|
+
sql += ` order by key ${options?.reverse ? 'desc' : 'asc'}`;
|
|
105
|
+
if (options?.limit !== undefined) {
|
|
106
|
+
sql += ` limit ${options.limit}`;
|
|
107
|
+
}
|
|
108
|
+
return { sql, params };
|
|
109
|
+
}
|
|
110
|
+
batch() {
|
|
111
|
+
this.checkOpen();
|
|
112
|
+
return new SQLiteWriteBatch(this);
|
|
113
|
+
}
|
|
114
|
+
async close() {
|
|
115
|
+
// Mark as closed but don't close the DB - it may be shared
|
|
116
|
+
this.closed = true;
|
|
117
|
+
}
|
|
118
|
+
async approximateCount(options) {
|
|
119
|
+
this.checkOpen();
|
|
120
|
+
if (!options?.gte && !options?.gt && !options?.lte && !options?.lt) {
|
|
121
|
+
// Fast path: count all rows
|
|
122
|
+
const rows = this.db.select(`select count(*) as cnt from ${this.tableName}`, []);
|
|
123
|
+
return rows[0]?.cnt ?? 0;
|
|
124
|
+
}
|
|
125
|
+
// With bounds, we need to count with conditions
|
|
126
|
+
const { sql, params } = this.buildIterateQuery(options);
|
|
127
|
+
const countSql = sql.replace(/^select key, value/, 'select count(*) as cnt').replace(/ order by.*$/, '');
|
|
128
|
+
const rows = this.db.select(countSql, params);
|
|
129
|
+
return rows[0]?.cnt ?? 0;
|
|
130
|
+
}
|
|
131
|
+
checkOpen() {
|
|
132
|
+
if (this.closed) {
|
|
133
|
+
throw new Error('SQLiteStore is closed');
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Execute a batch of operations atomically.
|
|
138
|
+
* Called by SQLiteWriteBatch.
|
|
139
|
+
*/
|
|
140
|
+
executeBatch(ops) {
|
|
141
|
+
this.checkOpen();
|
|
142
|
+
this.db.transaction(() => {
|
|
143
|
+
for (const op of ops) {
|
|
144
|
+
if (op.type === 'put') {
|
|
145
|
+
this.db.execute(this.sqlPut, [toArrayBuffer(op.key), toArrayBuffer(op.value)]);
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
this.db.execute(this.sqlDelete, [toArrayBuffer(op.key)]);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* WriteBatch implementation for SQLite.
|
|
156
|
+
*/
|
|
157
|
+
class SQLiteWriteBatch {
|
|
158
|
+
store;
|
|
159
|
+
ops = [];
|
|
160
|
+
constructor(store) {
|
|
161
|
+
this.store = store;
|
|
162
|
+
}
|
|
163
|
+
put(key, value) {
|
|
164
|
+
this.ops.push({ type: 'put', key, value });
|
|
165
|
+
}
|
|
166
|
+
delete(key) {
|
|
167
|
+
this.ops.push({ type: 'delete', key });
|
|
168
|
+
}
|
|
169
|
+
async write() {
|
|
170
|
+
if (this.ops.length > 0) {
|
|
171
|
+
this.store.executeBatch(this.ops);
|
|
172
|
+
this.ops = [];
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
clear() {
|
|
176
|
+
this.ops = [];
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
// ============================================================================
|
|
180
|
+
// Binary conversion utilities
|
|
181
|
+
// ============================================================================
|
|
182
|
+
/**
|
|
183
|
+
* Convert Uint8Array to ArrayBuffer for SQLite BLOB binding.
|
|
184
|
+
*/
|
|
185
|
+
function toArrayBuffer(bytes) {
|
|
186
|
+
// Create a new ArrayBuffer copy to handle views into SharedArrayBuffer
|
|
187
|
+
const copy = new ArrayBuffer(bytes.byteLength);
|
|
188
|
+
new Uint8Array(copy).set(bytes);
|
|
189
|
+
return copy;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Convert ArrayBuffer or Uint8Array to Uint8Array.
|
|
193
|
+
*/
|
|
194
|
+
function toUint8Array(data) {
|
|
195
|
+
if (data instanceof Uint8Array) {
|
|
196
|
+
return data;
|
|
197
|
+
}
|
|
198
|
+
return new Uint8Array(data);
|
|
199
|
+
}
|
|
200
|
+
//# sourceMappingURL=store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/store.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAyBH;;;;;GAKG;AACH,MAAM,OAAO,WAAW;IACd,EAAE,CAAiB;IACnB,SAAS,CAAS;IAClB,MAAM,GAAG,KAAK,CAAC;IAEvB,uCAAuC;IACtB,MAAM,CAAS;IACf,MAAM,CAAS;IACf,SAAS,CAAS;IAClB,MAAM,CAAS;IAEhC,YAAY,OAA2B;QACrC,IAAI,CAAC,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC;QAE3C,2BAA2B;QAC3B,IAAI,CAAC,MAAM,GAAG,qBAAqB,IAAI,CAAC,S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IAAI,WAAW,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAC/C,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAChC,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;GAEG;AACH,SAAS,YAAY,CAAC,IAA8B;IAClD,IAAI,IAAI,YAAY,UAAU,EAAE,CAAC;QAC/B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@quereus/plugin-nativescript-sqlite",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "NativeScript SQLite storage plugin for Quereus - mobile persistent storage",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"quereus",
|
|
8
|
+
"quereus-plugin",
|
|
9
|
+
"sql",
|
|
10
|
+
"database",
|
|
11
|
+
"storage",
|
|
12
|
+
"sqlite",
|
|
13
|
+
"nativescript",
|
|
14
|
+
"mobile",
|
|
15
|
+
"ios",
|
|
16
|
+
"android",
|
|
17
|
+
"kv-store",
|
|
18
|
+
"persistent"
|
|
19
|
+
],
|
|
20
|
+
"publisher": "Got Choices Foundation",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "https://github.com/gotchoices/quereus.git",
|
|
24
|
+
"directory": "packages/quereus-plugin-nativescript-sqlite"
|
|
25
|
+
},
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"main": "dist/src/index.js",
|
|
28
|
+
"types": "./dist/src/index.d.ts",
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"!**/*.tsbuildinfo"
|
|
32
|
+
],
|
|
33
|
+
"exports": {
|
|
34
|
+
".": {
|
|
35
|
+
"types": "./dist/src/index.d.ts",
|
|
36
|
+
"import": "./dist/src/index.js"
|
|
37
|
+
},
|
|
38
|
+
"./plugin": {
|
|
39
|
+
"types": "./dist/src/plugin.d.ts",
|
|
40
|
+
"import": "./dist/src/plugin.js"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"@nativescript-community/sqlite": "^3.0.0",
|
|
45
|
+
"@quereus/quereus": "^0.24.0",
|
|
46
|
+
"@quereus/store": "^0.3.5"
|
|
47
|
+
},
|
|
48
|
+
"engines": {
|
|
49
|
+
"quereus": "^0.24.0"
|
|
50
|
+
},
|
|
51
|
+
"quereus": {
|
|
52
|
+
"provides": {
|
|
53
|
+
"vtables": [
|
|
54
|
+
"store"
|
|
55
|
+
]
|
|
56
|
+
},
|
|
57
|
+
"settings": [
|
|
58
|
+
{
|
|
59
|
+
"key": "databasePath",
|
|
60
|
+
"label": "Database Path",
|
|
61
|
+
"type": "string",
|
|
62
|
+
"default": "quereus.db",
|
|
63
|
+
"help": "Path to the SQLite database file"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"key": "moduleName",
|
|
67
|
+
"label": "Module Name",
|
|
68
|
+
"type": "string",
|
|
69
|
+
"default": "store",
|
|
70
|
+
"help": "Name to register the virtual table module under"
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
"scripts": {
|
|
75
|
+
"clean": "rimraf dist",
|
|
76
|
+
"build": "tsc",
|
|
77
|
+
"typecheck": "tsc --noEmit",
|
|
78
|
+
"test": "cd ../.. && node --import ./packages/quereus-plugin-nativescript-sqlite/register.mjs node_modules/mocha/bin/mocha.js \"packages/quereus-plugin-nativescript-sqlite/test/**/*.spec.ts\" --colors"
|
|
79
|
+
},
|
|
80
|
+
"devDependencies": {
|
|
81
|
+
"@quereus/quereus": "*",
|
|
82
|
+
"@quereus/store": "*",
|
|
83
|
+
"@types/better-sqlite3": "^7.6.13",
|
|
84
|
+
"@types/chai": "^5.2.3",
|
|
85
|
+
"@types/mocha": "^10.0.10",
|
|
86
|
+
"@types/node": "^22.15.29",
|
|
87
|
+
"better-sqlite3": "^12.5.0",
|
|
88
|
+
"chai": "^6.2.2",
|
|
89
|
+
"mocha": "^11.7.5",
|
|
90
|
+
"rimraf": "^6.1.2",
|
|
91
|
+
"ts-node": "^10.9.2",
|
|
92
|
+
"typescript": "^5.8.3"
|
|
93
|
+
}
|
|
94
|
+
}
|