@quereus/plugin-leveldb 0.4.1 → 0.5.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 +27 -7
- 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 +17 -8
package/README.md
CHANGED
|
@@ -5,6 +5,7 @@ LevelDB storage plugin for Quereus. Provides persistent storage for Node.js envi
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
7
|
- **Fast**: LevelDB offers excellent read/write performance for key-value workloads
|
|
8
|
+
- **Transaction isolation**: Read-your-own-writes and snapshot isolation by default
|
|
8
9
|
- **Sorted keys**: Efficient range queries with ordered iteration
|
|
9
10
|
- **ACID batches**: Atomic writes across multiple keys
|
|
10
11
|
- **Compression**: Built-in Snappy compression for reduced disk usage
|
|
@@ -12,7 +13,7 @@ LevelDB storage plugin for Quereus. Provides persistent storage for Node.js envi
|
|
|
12
13
|
## Installation
|
|
13
14
|
|
|
14
15
|
```bash
|
|
15
|
-
npm install @quereus/plugin-leveldb @quereus/store
|
|
16
|
+
npm install @quereus/plugin-leveldb @quereus/store @quereus/isolation
|
|
16
17
|
```
|
|
17
18
|
|
|
18
19
|
## Quick Start
|
|
@@ -27,9 +28,26 @@ const db = new Database();
|
|
|
27
28
|
await registerPlugin(db, leveldbPlugin, { basePath: './data' });
|
|
28
29
|
|
|
29
30
|
await db.exec(`
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
create table users (id integer primary key, name text)
|
|
32
|
+
using store
|
|
32
33
|
`);
|
|
34
|
+
|
|
35
|
+
// Full transaction isolation enabled by default
|
|
36
|
+
await db.exec('BEGIN');
|
|
37
|
+
await db.exec(`INSERT INTO users VALUES (1, 'Alice')`);
|
|
38
|
+
const user = await db.get('SELECT * FROM users WHERE id = 1'); // Sees uncommitted insert
|
|
39
|
+
await db.exec('COMMIT');
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Disabling Isolation
|
|
43
|
+
|
|
44
|
+
If you need maximum performance and don't require read-your-own-writes within transactions:
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
await registerPlugin(db, leveldbPlugin, {
|
|
48
|
+
basePath: './data',
|
|
49
|
+
isolation: false // Disable isolation layer
|
|
50
|
+
});
|
|
33
51
|
```
|
|
34
52
|
|
|
35
53
|
### Direct Usage with Provider
|
|
@@ -37,16 +55,18 @@ await db.exec(`
|
|
|
37
55
|
```typescript
|
|
38
56
|
import { Database } from '@quereus/quereus';
|
|
39
57
|
import { createLevelDBProvider } from '@quereus/plugin-leveldb';
|
|
40
|
-
import {
|
|
58
|
+
import { createIsolatedStoreModule } from '@quereus/store';
|
|
41
59
|
|
|
42
60
|
const db = new Database();
|
|
43
61
|
const provider = createLevelDBProvider({ basePath: './data' });
|
|
44
|
-
|
|
62
|
+
|
|
63
|
+
// With isolation (recommended)
|
|
64
|
+
const storeModule = createIsolatedStoreModule({ provider });
|
|
45
65
|
db.registerModule('store', storeModule);
|
|
46
66
|
|
|
47
67
|
await db.exec(`
|
|
48
|
-
|
|
49
|
-
|
|
68
|
+
create table users (id integer primary key, name text)
|
|
69
|
+
using store
|
|
50
70
|
`);
|
|
51
71
|
```
|
|
52
72
|
|
package/dist/src/plugin.d.ts
CHANGED
|
@@ -25,6 +25,12 @@ export interface LevelDBPluginConfig {
|
|
|
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 LevelDB plugin with a database.
|
|
@@ -32,7 +38,7 @@ export interface LevelDBPluginConfig {
|
|
|
32
38
|
export default function register(_db: Database, config?: Record<string, SqlValue>): {
|
|
33
39
|
vtables: {
|
|
34
40
|
name: string;
|
|
35
|
-
module: StoreModule;
|
|
41
|
+
module: import("@quereus/isolation").IsolationModule | StoreModule;
|
|
36
42
|
}[];
|
|
37
43
|
};
|
|
38
44
|
//# 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;AAGxE;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAC/B,GAAG,EAAE,QAAQ,EACb,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAM;;;;;EAwBrC"}
|
package/dist/src/plugin.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Registers a StoreModule backed by LevelDB for Node.js environments.
|
|
5
5
|
*/
|
|
6
|
-
import { StoreModule } from '@quereus/store';
|
|
6
|
+
import { StoreModule, createIsolatedStoreModule } from '@quereus/store';
|
|
7
7
|
import { LevelDBProvider } from './provider.js';
|
|
8
8
|
/**
|
|
9
9
|
* Register the LevelDB plugin with a database.
|
|
@@ -12,11 +12,14 @@ export default function register(_db, config = {}) {
|
|
|
12
12
|
const basePath = config.basePath ?? './data';
|
|
13
13
|
const createIfMissing = config.createIfMissing !== false;
|
|
14
14
|
const moduleName = config.moduleName ?? 'store';
|
|
15
|
+
const isolation = config.isolation ?? true;
|
|
15
16
|
const provider = new LevelDBProvider({
|
|
16
17
|
basePath,
|
|
17
18
|
createIfMissing,
|
|
18
19
|
});
|
|
19
|
-
const storeModule =
|
|
20
|
+
const storeModule = isolation
|
|
21
|
+
? createIsolatedStoreModule({ provider })
|
|
22
|
+
: new StoreModule(provider);
|
|
20
23
|
return {
|
|
21
24
|
vtables: [
|
|
22
25
|
{
|
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,eAAe,EAAE,MAAM,eAAe,CAAC;AAiChD;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAC/B,GAAa,EACb,SAAmC,EAAE;IAErC,MAAM,QAAQ,GAAI,MAAM,CAAC,QAAmB,IAAI,QAAQ,CAAC;IACzD,MAAM,eAAe,GAAG,MAAM,CAAC,eAAe,KAAK,KAAK,CAAC;IACzD,MAAM,UAAU,GAAI,MAAM,CAAC,UAAqB,IAAI,OAAO,CAAC;IAC5D,MAAM,SAAS,GAAI,MAAM,CAAC,SAAqB,IAAI,IAAI,CAAC;IAExD,MAAM,QAAQ,GAAG,IAAI,eAAe,CAAC;QACpC,QAAQ;QACR,eAAe;KACf,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-leveldb",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "LevelDB storage plugin for Quereus - Node.js persistent storage",
|
|
6
6
|
"keywords": [
|
|
@@ -37,8 +37,9 @@
|
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"@quereus/
|
|
41
|
-
"@quereus/
|
|
40
|
+
"@quereus/isolation": "^0.2.1",
|
|
41
|
+
"@quereus/quereus": "^0.14.0",
|
|
42
|
+
"@quereus/store": "^0.6.1"
|
|
42
43
|
},
|
|
43
44
|
"engines": {
|
|
44
45
|
"quereus": "^0.24.0"
|
|
@@ -70,6 +71,13 @@
|
|
|
70
71
|
"type": "string",
|
|
71
72
|
"default": "store",
|
|
72
73
|
"help": "Name to register the virtual table module under"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"key": "isolation",
|
|
77
|
+
"label": "Transaction Isolation",
|
|
78
|
+
"type": "boolean",
|
|
79
|
+
"default": true,
|
|
80
|
+
"help": "Enable transaction isolation (read-your-own-writes, snapshot isolation)"
|
|
73
81
|
}
|
|
74
82
|
]
|
|
75
83
|
},
|
|
@@ -80,17 +88,18 @@
|
|
|
80
88
|
"test": "cd ../.. && node --import ./packages/quereus-plugin-leveldb/register.mjs node_modules/mocha/bin/mocha.js \"packages/quereus-plugin-leveldb/test/**/*.spec.ts\" --colors"
|
|
81
89
|
},
|
|
82
90
|
"dependencies": {
|
|
83
|
-
"classic-level": "^
|
|
91
|
+
"classic-level": "^3.0.0"
|
|
84
92
|
},
|
|
85
93
|
"devDependencies": {
|
|
94
|
+
"@quereus/isolation": "*",
|
|
86
95
|
"@quereus/quereus": "*",
|
|
87
96
|
"@quereus/store": "*",
|
|
88
97
|
"@types/mocha": "^10.0.10",
|
|
89
|
-
"@types/node": "^
|
|
90
|
-
"chai": "^
|
|
91
|
-
"mocha": "^11.5
|
|
98
|
+
"@types/node": "^25.0.9",
|
|
99
|
+
"chai": "^6.2.2",
|
|
100
|
+
"mocha": "^11.7.5",
|
|
92
101
|
"rimraf": "^6.1.2",
|
|
93
102
|
"ts-node": "^10.9.2",
|
|
94
|
-
"typescript": "^5.
|
|
103
|
+
"typescript": "^5.9.3"
|
|
95
104
|
}
|
|
96
105
|
}
|