jexidb 2.2.2 β 2.2.5
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 +50 -0
- package/dist/Database.cjs +538 -56
- package/package.json +1 -1
- package/src/Database.mjs +274 -28
- package/src/FileHandler.mjs +88 -1
- package/src/managers/IndexManager.mjs +66 -7
- package/src/managers/QueryManager.mjs +69 -14
- package/src/utils/ioTimeout.mjs +36 -0
package/README.md
CHANGED
|
@@ -338,6 +338,48 @@ const multiTypeCoverage = await db.coverage('tags', [
|
|
|
338
338
|
], { mediaType: ['live', 'vod'] }) // Live OR VOD content
|
|
339
339
|
```
|
|
340
340
|
|
|
341
|
+
### Fast Partial & Regex Searches
|
|
342
|
+
|
|
343
|
+
Raw `RegExp` conditions on indexed `string` / term-mapped fields are resolved against the
|
|
344
|
+
index keys instead of streaming the whole data file, so partial searches stay fast:
|
|
345
|
+
|
|
346
|
+
```javascript
|
|
347
|
+
const results = await db.find({ nameTerms: /^glo/i }) // Indexed regex (v2.2.5+)
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
In streaming queries, indexed conditions are pre-filtered first and residual conditions such
|
|
351
|
+
as `$ne` / `$nin` are applied last over the reduced candidate set:
|
|
352
|
+
|
|
353
|
+
```javascript
|
|
354
|
+
const liveItems = await db.find({
|
|
355
|
+
$and: [{ nameTerms: /news/i }, { mediaType: { $ne: 'video' } }]
|
|
356
|
+
})
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
> Numeric indexes still use streaming for regex conditions (regex over numbers is not
|
|
360
|
+
> meaningful). With `indexedQueryMode: 'strict'`, residual operators such as `$ne` require
|
|
361
|
+
> `allowNonIndexed: true` to pass query validation.
|
|
362
|
+
|
|
363
|
+
## Read & Write Safety
|
|
364
|
+
|
|
365
|
+
The following constructor options control recovery, memory use, and reader/writer
|
|
366
|
+
coordination (also listed in the [API reference](docs/API.md)):
|
|
367
|
+
|
|
368
|
+
| Option | Default | Purpose |
|
|
369
|
+
|--------|---------|---------|
|
|
370
|
+
| `readOnly` | `false` | Open for reads only: never creates, writes, rebuilds or auto-flushes |
|
|
371
|
+
| `updatingSentinel` | `false` | Writer mode: exposes `<file>.updating.jdb` while saving so cross-process readers can skip in-place refresh/repair |
|
|
372
|
+
| `allowIndexRebuild` | `false` | Rebuild a missing/corrupt index on first query (default throws) |
|
|
373
|
+
| `indexIdleUnloadMs` | `30000` | Unload the in-memory index after inactivity (`0` disables) |
|
|
374
|
+
| `ioTimeoutMs` | `0` | I/O timeout for streaming reads / index rebuilds (`0` disables) |
|
|
375
|
+
| `maxRetries` | `3` | Retry count for timed-out reads / index rebuilds |
|
|
376
|
+
|
|
377
|
+
Data and index saves are atomic (unique temp file + rename, with a Windows-safe fallback),
|
|
378
|
+
and indexed readers detect a file swap and reload offsets + index from the current `.idx`.
|
|
379
|
+
Atomic saves prevent half-written files and temp collisions; they do not merge simultaneous
|
|
380
|
+
application writes, so keep a single writer (or coordinate via `updatingSentinel`) when
|
|
381
|
+
multiple instances can modify the same database.
|
|
382
|
+
|
|
341
383
|
## Testes
|
|
342
384
|
|
|
343
385
|
JexiDB inclui uma suΓte completa de testes com Jest:
|
|
@@ -426,6 +468,14 @@ MIT License - see the [LICENSE](LICENSE) file for details.
|
|
|
426
468
|
- π **Advanced Analytics** - Built-in data analysis tools
|
|
427
469
|
|
|
428
470
|
### Recent Updates
|
|
471
|
+
- β
**v2.2.5** - Faster indexed regex/partial search, smarter streaming pre-filtering, sampled debug logs, and race-free concurrent atomic saves (see [CHANGELOG](CHANGELOG.md))
|
|
472
|
+
- β
**v2.2.4** - Read/write safety hardening (see [CHANGELOG](CHANGELOG.md)):
|
|
473
|
+
- Atomic data-file saves (temp + rename) - readers never see a half-written file
|
|
474
|
+
- Reader-side file-swap detection with clean reload on indexed reads
|
|
475
|
+
- Optional writer sentinel (`updatingSentinel`) for cross-process coordination
|
|
476
|
+
- I/O timeouts/aborts surface as retriable errors (no more `uncaughtException`)
|
|
477
|
+
- Idle-unload recovery via on-disk index reload (no forced rebuild/throw)
|
|
478
|
+
- New `readOnly` mode; single-flight lazy index loading
|
|
429
479
|
- β
**v2.1.0** - Term mapping auto-detection, 77% size reduction
|
|
430
480
|
- β
**Schema Enforcement** - Mandatory fields for data consistency
|
|
431
481
|
- β
**Streaming Operations** - Memory-efficient bulk operations
|