deepbase-sqlite 3.6.0 → 3.6.4
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 +58 -7
- package/package.json +2 -2
- package/src/SqliteDriver.js +27 -1
package/README.md
CHANGED
|
@@ -5,9 +5,14 @@ SQLite driver for DeepBase.
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install deepbase deepbase-sqlite
|
|
8
|
+
npm install deepbase deepbase-sqlite --ignore-scripts=false
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
> `deepbase-sqlite` depends on `better-sqlite3`, a native module. Its install
|
|
12
|
+
> script downloads a prebuilt binary (or compiles from source as a fallback).
|
|
13
|
+
> If your environment disables npm lifecycle scripts, see
|
|
14
|
+
> [Troubleshooting](#troubleshooting) below.
|
|
15
|
+
|
|
11
16
|
## Description
|
|
12
17
|
|
|
13
18
|
Stores data in SQLite database files. Perfect for:
|
|
@@ -143,12 +148,12 @@ CREATE TABLE deepbase (
|
|
|
143
148
|
Example data:
|
|
144
149
|
|
|
145
150
|
```
|
|
146
|
-
key
|
|
147
|
-
|
|
148
|
-
users.alice.name
|
|
149
|
-
users.alice.age
|
|
150
|
-
users.bob.name
|
|
151
|
-
users.bob.age
|
|
151
|
+
key | value
|
|
152
|
+
----------------------|------------------
|
|
153
|
+
users.alice.name | "Alice"
|
|
154
|
+
users.alice.age | 30
|
|
155
|
+
users.bob.name | "Bob"
|
|
156
|
+
users.bob.age | 25
|
|
152
157
|
config.theme | "dark"
|
|
153
158
|
config.lang | "en"
|
|
154
159
|
```
|
|
@@ -264,6 +269,52 @@ await db.set('users', userId, 'profile', data);
|
|
|
264
269
|
await db.set(`user_${userId}_profile`, data);
|
|
265
270
|
```
|
|
266
271
|
|
|
272
|
+
## Troubleshooting
|
|
273
|
+
|
|
274
|
+
### `Could not locate the bindings file` / `better_sqlite3.node` missing
|
|
275
|
+
|
|
276
|
+
This error means `better-sqlite3`'s native binding was never fetched or built.
|
|
277
|
+
It almost always comes from npm install scripts being disabled, which prevents
|
|
278
|
+
`better-sqlite3`'s `install` script from downloading the prebuilt binary.
|
|
279
|
+
|
|
280
|
+
Check whether scripts are disabled:
|
|
281
|
+
|
|
282
|
+
```bash
|
|
283
|
+
npm config get ignore-scripts # should be "false"
|
|
284
|
+
cat ~/.npmrc 2>/dev/null # look for `ignore-scripts=true`
|
|
285
|
+
cat .npmrc 2>/dev/null
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
Fix — rebuild the native binding in the project that uses `deepbase-sqlite`:
|
|
289
|
+
|
|
290
|
+
```bash
|
|
291
|
+
npm rebuild better-sqlite3 --ignore-scripts=false
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
If `npm rebuild` still doesn't fetch a prebuild (common when `ignore-scripts`
|
|
295
|
+
is persisted in `.npmrc`), do a clean reinstall of just that package:
|
|
296
|
+
|
|
297
|
+
```bash
|
|
298
|
+
rm -rf node_modules/better-sqlite3
|
|
299
|
+
npm i --ignore-scripts=false
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
Verify the binding landed:
|
|
303
|
+
|
|
304
|
+
```bash
|
|
305
|
+
ls node_modules/better-sqlite3/build/Release/better_sqlite3.node
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
Notes:
|
|
309
|
+
|
|
310
|
+
- `npm i <pkg> --ignore-scripts=false` only runs scripts if the install
|
|
311
|
+
actually changes `node_modules`. When npm reports `up to date`, no install
|
|
312
|
+
scripts run — use `npm rebuild` or remove the package folder first.
|
|
313
|
+
- In monorepos or CI, prefer setting `ignore-scripts=false` for the install
|
|
314
|
+
step rather than passing it as a one-off flag.
|
|
315
|
+
- When this happens at runtime, `deepbase-sqlite` will throw an error with
|
|
316
|
+
code `DEEPBASE_SQLITE_BINDING_MISSING` and a pointer back to this section.
|
|
317
|
+
|
|
267
318
|
## License
|
|
268
319
|
|
|
269
320
|
MIT - Copyright (c) Martin Clasen
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "deepbase-sqlite",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.4",
|
|
4
4
|
"description": "⚡ DeepBase SQLite - SQLite database driver",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.cjs",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"better-sqlite3": "^11.8.1"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
|
-
"deepbase": "^3.6.
|
|
20
|
+
"deepbase": "^3.6.4"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
23
|
"test": "mocha test/test.js"
|
package/src/SqliteDriver.js
CHANGED
|
@@ -59,7 +59,23 @@ export class SqliteDriver extends DeepBaseDriver {
|
|
|
59
59
|
fs.mkdirSync(this.path, { recursive: true });
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
try {
|
|
63
|
+
this.db = new Database(this.fileName);
|
|
64
|
+
} catch (err) {
|
|
65
|
+
if (this._isMissingNativeBinding(err)) {
|
|
66
|
+
const hint =
|
|
67
|
+
'deepbase-sqlite: the native binding for "better-sqlite3" is missing. ' +
|
|
68
|
+
'This usually means npm install scripts were disabled (e.g. `ignore-scripts=true` in your .npmrc). ' +
|
|
69
|
+
'Fix it with: `npm rebuild better-sqlite3 --ignore-scripts=false`, ' +
|
|
70
|
+
'or reinstall with `npm i --ignore-scripts=false`. ' +
|
|
71
|
+
'See https://github.com/clasen/DeepBase/tree/main/packages/driver-sqlite#troubleshooting';
|
|
72
|
+
const wrapped = new Error(hint);
|
|
73
|
+
wrapped.cause = err;
|
|
74
|
+
wrapped.code = 'DEEPBASE_SQLITE_BINDING_MISSING';
|
|
75
|
+
throw wrapped;
|
|
76
|
+
}
|
|
77
|
+
throw err;
|
|
78
|
+
}
|
|
63
79
|
|
|
64
80
|
const cfg = PRAGMA[this.pragma];
|
|
65
81
|
if (cfg) {
|
|
@@ -257,6 +273,16 @@ export class SqliteDriver extends DeepBaseDriver {
|
|
|
257
273
|
return result;
|
|
258
274
|
}
|
|
259
275
|
|
|
276
|
+
_isMissingNativeBinding(err) {
|
|
277
|
+
if (!err) return false;
|
|
278
|
+
const msg = String(err.message || '');
|
|
279
|
+
return (
|
|
280
|
+
err.code === 'MODULE_NOT_FOUND' ||
|
|
281
|
+
msg.includes('Could not locate the bindings file') ||
|
|
282
|
+
msg.includes('better_sqlite3.node')
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
|
|
260
286
|
_escapeLikePattern(str) {
|
|
261
287
|
return str.replace(/[!%_]/g, '!$&');
|
|
262
288
|
}
|