@quereus/plugin-nativescript-sqlite 0.3.1 → 0.4.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 +21 -6
- package/dist/src/plugin.d.ts +7 -1
- package/dist/src/plugin.d.ts.map +1 -1
- package/dist/src/plugin.js +5 -2
- package/dist/src/plugin.js.map +1 -1
- package/package.json +15 -6
package/README.md
CHANGED
|
@@ -5,6 +5,7 @@ SQLite storage plugin for Quereus on NativeScript. Provides persistent storage f
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
7
|
- **Native SQLite**: Uses the device's built-in SQLite via `@nativescript-community/sqlite`
|
|
8
|
+
- **Transaction isolation**: Read-your-own-writes and snapshot isolation by default
|
|
8
9
|
- **Order-preserving keys**: BLOB keys with `memcmp()` comparison ensure correct lexicographic byte ordering
|
|
9
10
|
- **Single database file**: All stores share one SQLite database (separate tables)
|
|
10
11
|
- **ACID transactions**: SQLite transactions for atomic batch writes
|
|
@@ -13,7 +14,7 @@ SQLite storage plugin for Quereus on NativeScript. Provides persistent storage f
|
|
|
13
14
|
## Installation
|
|
14
15
|
|
|
15
16
|
```bash
|
|
16
|
-
npm install @quereus/plugin-nativescript-sqlite @quereus/store @nativescript-community/sqlite
|
|
17
|
+
npm install @quereus/plugin-nativescript-sqlite @quereus/store @quereus/isolation @nativescript-community/sqlite
|
|
17
18
|
```
|
|
18
19
|
|
|
19
20
|
Or with NativeScript CLI:
|
|
@@ -41,13 +42,26 @@ await registerPlugin(db, sqlitePlugin, { db: sqliteDb });
|
|
|
41
42
|
|
|
42
43
|
// Create tables using the 'store' module
|
|
43
44
|
await db.exec(`
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
create table users (id integer primary key, name text)
|
|
46
|
+
using store
|
|
46
47
|
`);
|
|
47
48
|
|
|
48
|
-
//
|
|
49
|
+
// Full transaction isolation enabled by default
|
|
50
|
+
await db.exec('BEGIN');
|
|
49
51
|
await db.exec(`insert into users values (1, 'Alice')`);
|
|
50
|
-
const
|
|
52
|
+
const user = await db.get(`select * from users where id = 1`); // Sees uncommitted insert
|
|
53
|
+
await db.exec('COMMIT');
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Disabling Isolation
|
|
57
|
+
|
|
58
|
+
If you need maximum performance and don't require read-your-own-writes within transactions:
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
await registerPlugin(db, sqlitePlugin, {
|
|
62
|
+
db: sqliteDb,
|
|
63
|
+
isolation: false // Disable isolation layer
|
|
64
|
+
});
|
|
51
65
|
```
|
|
52
66
|
|
|
53
67
|
### Direct Usage with Provider
|
|
@@ -56,7 +70,8 @@ const users = await db.all(`select * from users`);
|
|
|
56
70
|
import { openOrCreate } from '@nativescript-community/sqlite';
|
|
57
71
|
import { Database } from '@quereus/quereus';
|
|
58
72
|
import { createSQLiteProvider } from '@quereus/plugin-nativescript-sqlite';
|
|
59
|
-
import {
|
|
73
|
+
import { createIsolatedStoreModule } from '@quereus/store';
|
|
74
|
+
|
|
60
75
|
|
|
61
76
|
const sqliteDb = openOrCreate('quereus.db');
|
|
62
77
|
const provider = createSQLiteProvider({ db: sqliteDb });
|
package/dist/src/plugin.d.ts
CHANGED
|
@@ -25,6 +25,12 @@ export interface SQLitePluginConfig {
|
|
|
25
25
|
* @default 'store'
|
|
26
26
|
*/
|
|
27
27
|
moduleName?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Enable transaction isolation (read-your-own-writes, snapshot isolation).
|
|
30
|
+
* When true, wraps the store module with an isolation layer.
|
|
31
|
+
* @default true
|
|
32
|
+
*/
|
|
33
|
+
isolation?: boolean;
|
|
28
34
|
}
|
|
29
35
|
/**
|
|
30
36
|
* Register the NativeScript SQLite plugin with a database.
|
|
@@ -48,7 +54,7 @@ export interface SQLitePluginConfig {
|
|
|
48
54
|
export default function register(_db: Database, config?: Record<string, SqlValue>): {
|
|
49
55
|
vtables: {
|
|
50
56
|
name: string;
|
|
51
|
-
module: StoreModule;
|
|
57
|
+
module: import("@quereus/isolation").IsolationModule | StoreModule;
|
|
52
58
|
}[];
|
|
53
59
|
};
|
|
54
60
|
//# sourceMappingURL=plugin.d.ts.map
|
package/dist/src/plugin.d.ts.map
CHANGED
|
@@ -1 +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,
|
|
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,EAA6B,MAAM,gBAAgB,CAAC;AAExE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC;;;OAGG;IACH,EAAE,EAAE,cAAc,CAAC;IAEnB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAC/B,GAAG,EAAE,QAAQ,EACb,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAM;;;;;EAgCrC"}
|
package/dist/src/plugin.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Registers a StoreModule backed by SQLite for NativeScript mobile environments.
|
|
5
5
|
*/
|
|
6
|
-
import { StoreModule } from '@quereus/store';
|
|
6
|
+
import { StoreModule, createIsolatedStoreModule } from '@quereus/store';
|
|
7
7
|
import { SQLiteProvider } from './provider.js';
|
|
8
8
|
/**
|
|
9
9
|
* Register the NativeScript SQLite plugin with a database.
|
|
@@ -33,11 +33,14 @@ export default function register(_db, config = {}) {
|
|
|
33
33
|
}
|
|
34
34
|
const tablePrefix = config.tablePrefix ?? 'quereus_';
|
|
35
35
|
const moduleName = config.moduleName ?? 'store';
|
|
36
|
+
const isolation = config.isolation ?? true;
|
|
36
37
|
const provider = new SQLiteProvider({
|
|
37
38
|
db: sqliteDb,
|
|
38
39
|
tablePrefix,
|
|
39
40
|
});
|
|
40
|
-
const storeModule =
|
|
41
|
+
const storeModule = isolation
|
|
42
|
+
? createIsolatedStoreModule({ provider })
|
|
43
|
+
: new StoreModule(provider);
|
|
41
44
|
return {
|
|
42
45
|
vtables: [
|
|
43
46
|
{
|
package/dist/src/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,WAAW,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAiC/C;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAC/B,GAAa,EACb,SAAmC,EAAE;IAErC,uCAAuC;IACvC,MAAM,QAAQ,GAAG,MAAM,CAAC,EAA+B,CAAC;IACxD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACd,2FAA2F;YAC3F,uEAAuE,CACvE,CAAC;IACH,CAAC;IAED,MAAM,WAAW,GAAI,MAAM,CAAC,WAAsB,IAAI,UAAU,CAAC;IACjE,MAAM,UAAU,GAAI,MAAM,CAAC,UAAqB,IAAI,OAAO,CAAC;IAC5D,MAAM,SAAS,GAAI,MAAM,CAAC,SAAqB,IAAI,IAAI,CAAC;IAExD,MAAM,QAAQ,GAAG,IAAI,cAAc,CAAC;QACnC,EAAE,EAAE,QAAQ;QACZ,WAAW;KACX,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,SAAS;QAC5B,CAAC,CAAC,yBAAyB,CAAC,EAAE,QAAQ,EAAE,CAAC;QACzC,CAAC,CAAC,IAAI,WAAW,CAAC,QAAQ,CAAC,CAAC;IAE7B,OAAO;QACN,OAAO,EAAE;YACR;gBACC,IAAI,EAAE,UAAU;gBAChB,MAAM,EAAE,WAAW;aACnB;SACD;KACD,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quereus/plugin-nativescript-sqlite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "NativeScript SQLite storage plugin for Quereus - mobile persistent storage",
|
|
6
6
|
"keywords": [
|
|
@@ -42,8 +42,9 @@
|
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"@nativescript-community/sqlite": "^3.0.0",
|
|
45
|
-
"@quereus/
|
|
46
|
-
"@quereus/
|
|
45
|
+
"@quereus/isolation": "^0.2.1",
|
|
46
|
+
"@quereus/quereus": "^0.14.0",
|
|
47
|
+
"@quereus/store": "^0.6.1"
|
|
47
48
|
},
|
|
48
49
|
"engines": {
|
|
49
50
|
"quereus": "^0.24.0"
|
|
@@ -68,6 +69,13 @@
|
|
|
68
69
|
"type": "string",
|
|
69
70
|
"default": "store",
|
|
70
71
|
"help": "Name to register the virtual table module under"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"key": "isolation",
|
|
75
|
+
"label": "Transaction Isolation",
|
|
76
|
+
"type": "boolean",
|
|
77
|
+
"default": true,
|
|
78
|
+
"help": "Enable transaction isolation (read-your-own-writes, snapshot isolation)"
|
|
71
79
|
}
|
|
72
80
|
]
|
|
73
81
|
},
|
|
@@ -78,17 +86,18 @@
|
|
|
78
86
|
"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
87
|
},
|
|
80
88
|
"devDependencies": {
|
|
89
|
+
"@quereus/isolation": "*",
|
|
81
90
|
"@quereus/quereus": "*",
|
|
82
91
|
"@quereus/store": "*",
|
|
83
92
|
"@types/better-sqlite3": "^7.6.13",
|
|
84
93
|
"@types/chai": "^5.2.3",
|
|
85
94
|
"@types/mocha": "^10.0.10",
|
|
86
|
-
"@types/node": "^
|
|
87
|
-
"better-sqlite3": "^12.
|
|
95
|
+
"@types/node": "^25.0.9",
|
|
96
|
+
"better-sqlite3": "^12.6.0",
|
|
88
97
|
"chai": "^6.2.2",
|
|
89
98
|
"mocha": "^11.7.5",
|
|
90
99
|
"rimraf": "^6.1.2",
|
|
91
100
|
"ts-node": "^10.9.2",
|
|
92
|
-
"typescript": "^5.
|
|
101
|
+
"typescript": "^5.9.3"
|
|
93
102
|
}
|
|
94
103
|
}
|