jexidb 2.1.5 → 2.1.7
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 +460 -449
- package/dist/Database.cjs +1321 -259
- package/package.json +3 -2
- package/src/Database.mjs +674 -136
- package/src/FileHandler.mjs +92 -32
- package/src/managers/QueryManager.mjs +13 -7
- package/src/managers/TermManager.mjs +7 -0
package/README.md
CHANGED
|
@@ -1,449 +1,460 @@
|
|
|
1
|
-
# JexiDB - Intelligent JavaScript Database for Desktop Apps
|
|
2
|
-
|
|
3
|
-
**JEXIDB** = **J**avaScript **EX**tended **I**ntelligent **D**ata**B**ase
|
|
4
|
-
|
|
5
|
-
**The Only Pure JS Database with Smart Disk Persistence & Intelligent Memory Management** - Schema-Enforced, Streaming-Ready, No Native Dependencies
|
|
6
|
-
|
|
7
|
-
<p align="center">
|
|
8
|
-
<img width="270" src="https://edenware.app/jexidb/images/jexidb-logo-icon.jpg" alt="JexiDB - JavaScript EXtended Intelligent DataBase for Node.js and Electron applications" title="JexiDB - JavaScript EXtended Intelligent DataBase logo" />
|
|
9
|
-
</p>
|
|
10
|
-
|
|
11
|
-
<div align="center">
|
|
12
|
-
|
|
13
|
-
[](https://www.npmjs.com/package/jexidb)
|
|
14
|
-
[](https://www.npmjs.com/package/jexidb)
|
|
15
|
-
[](https://opensource.org/licenses/MIT)
|
|
16
|
-
[](https://nodejs.org/)
|
|
17
|
-
[](https://github.com/EdenwareApps/jexidb)
|
|
18
|
-
[](https://github.com/EdenwareApps/jexidb/issues)
|
|
19
|
-
|
|
20
|
-
**⚡ High-Performance • 💾 Persistent • 🧠 Memory Efficient • 🚀 Production Ready**
|
|
21
|
-
|
|
22
|
-
[📖 Documentation](docs/README.md) • [💡 Examples](docs/EXAMPLES.md) • [🔧 API Reference](docs/API.md) • [🚀 Quick Start](#quick-start---5-minutes-to-database)
|
|
23
|
-
|
|
24
|
-
</div>
|
|
25
|
-
|
|
26
|
-
## Table of Contents
|
|
27
|
-
|
|
28
|
-
- [Why Developers Choose JexiDB](#why-developers-choose-jexidb)
|
|
29
|
-
- [JexiDB vs Other JavaScript Databases](#jexidb-vs-other-javascript-databases)
|
|
30
|
-
- [Performance Benchmarks](#performance-benchmarks)
|
|
31
|
-
- [Frequently Asked Questions](#frequently-asked-questions)
|
|
32
|
-
- [Quick Start - 5 Minutes to Database](#quick-start---5-minutes-to-database)
|
|
33
|
-
- [Real-World Use Cases](#real-world-use-cases)
|
|
34
|
-
- [Migration Guide](#migration-guide)
|
|
35
|
-
- [What's Next - Roadmap](#whats-next---roadmap)
|
|
36
|
-
|
|
37
|
-
---
|
|
38
|
-
|
|
39
|
-
## What Makes JexiDB Unique
|
|
40
|
-
|
|
41
|
-
**The Only Pure JS Database with Smart Disk Persistence & Intelligent Memory Management**
|
|
42
|
-
|
|
43
|
-
JexiDB stands out among JavaScript databases by combining **pure JavaScript simplicity** with **enterprise-grade data management**. While other JS databases offer basic persistence, JexiDB provides **intelligent memory management** and **structured data enforcement** that traditional document databases lack.
|
|
44
|
-
|
|
45
|
-
### Unique Advantages Over Other JavaScript Databases
|
|
46
|
-
|
|
47
|
-
🚀 **Pure JavaScript, No Compromises** - 100% JavaScript, no native dependencies, WASM, or compilation required. Compatible with both CommonJS and ESM modules
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
- **
|
|
58
|
-
|
|
59
|
-
- **
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
- **
|
|
64
|
-
- **
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
**
|
|
80
|
-
|
|
81
|
-
**
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
**
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
###
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
###
|
|
147
|
-
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
//
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
//
|
|
199
|
-
const
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
//
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
//
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
//
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
- **
|
|
261
|
-
- **
|
|
262
|
-
- **
|
|
263
|
-
- **
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
//
|
|
277
|
-
for await (const
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
'
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
});
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
##
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
-
|
|
445
|
-
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
1
|
+
# JexiDB - Intelligent JavaScript Database for Desktop Apps
|
|
2
|
+
|
|
3
|
+
**JEXIDB** = **J**avaScript **EX**tended **I**ntelligent **D**ata**B**ase
|
|
4
|
+
|
|
5
|
+
**The Only Pure JS Database with Smart Disk Persistence & Intelligent Memory Management** - Schema-Enforced, Streaming-Ready, No Native Dependencies
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<img width="270" src="https://edenware.app/jexidb/images/jexidb-logo-icon.jpg" alt="JexiDB - JavaScript EXtended Intelligent DataBase for Node.js and Electron applications" title="JexiDB - JavaScript EXtended Intelligent DataBase logo" />
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<div align="center">
|
|
12
|
+
|
|
13
|
+
[](https://www.npmjs.com/package/jexidb)
|
|
14
|
+
[](https://www.npmjs.com/package/jexidb)
|
|
15
|
+
[](https://opensource.org/licenses/MIT)
|
|
16
|
+
[](https://nodejs.org/)
|
|
17
|
+
[](https://github.com/EdenwareApps/jexidb)
|
|
18
|
+
[](https://github.com/EdenwareApps/jexidb/issues)
|
|
19
|
+
|
|
20
|
+
**⚡ High-Performance • 💾 Persistent • 🧠 Memory Efficient • 🚀 Production Ready**
|
|
21
|
+
|
|
22
|
+
[📖 Documentation](docs/README.md) • [💡 Examples](docs/EXAMPLES.md) • [🔧 API Reference](docs/API.md) • [🚀 Quick Start](#quick-start---5-minutes-to-database)
|
|
23
|
+
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
## Table of Contents
|
|
27
|
+
|
|
28
|
+
- [Why Developers Choose JexiDB](#why-developers-choose-jexidb)
|
|
29
|
+
- [JexiDB vs Other JavaScript Databases](#jexidb-vs-other-javascript-databases)
|
|
30
|
+
- [Performance Benchmarks](#performance-benchmarks)
|
|
31
|
+
- [Frequently Asked Questions](#frequently-asked-questions)
|
|
32
|
+
- [Quick Start - 5 Minutes to Database](#quick-start---5-minutes-to-database)
|
|
33
|
+
- [Real-World Use Cases](#real-world-use-cases)
|
|
34
|
+
- [Migration Guide](#migration-guide)
|
|
35
|
+
- [What's Next - Roadmap](#whats-next---roadmap)
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## What Makes JexiDB Unique
|
|
40
|
+
|
|
41
|
+
**The Only Pure JS Database with Smart Disk Persistence & Intelligent Memory Management**
|
|
42
|
+
|
|
43
|
+
JexiDB stands out among JavaScript databases by combining **pure JavaScript simplicity** with **enterprise-grade data management**. While other JS databases offer basic persistence, JexiDB provides **intelligent memory management** and **structured data enforcement** that traditional document databases lack.
|
|
44
|
+
|
|
45
|
+
### Unique Advantages Over Other JavaScript Databases
|
|
46
|
+
|
|
47
|
+
🚀 **Pure JavaScript, No Compromises** - 100% JavaScript, no native dependencies, WASM, or compilation required. Compatible with both CommonJS and ESM modules
|
|
48
|
+
|
|
49
|
+
💾 **Intelligent Disk Persistence** - JSONL files with compressed persistent indexes, not memory-only storage
|
|
50
|
+
|
|
51
|
+
📋 **Schema Enforcement** - Structured data model like SQL tables, ensuring data consistency in pure JavaScript
|
|
52
|
+
|
|
53
|
+
🧠 **Smart Memory Management** - Point reading and streaming operations, handles millions of records without loading everything into RAM
|
|
54
|
+
|
|
55
|
+
🔍 **Advanced Query Optimization** - MongoDB-like operators with automatic term mapping for 77% size reduction
|
|
56
|
+
|
|
57
|
+
⚡ **Production-Ready Performance** - Compressed indexes, streaming operations, and automatic optimization
|
|
58
|
+
|
|
59
|
+
🖥️ **Desktop-First Design** - Optimized for Electron, NW.js, and local Node.js applications from the ground up
|
|
60
|
+
|
|
61
|
+
### Technical Specifications
|
|
62
|
+
|
|
63
|
+
- **Storage Format**: JSONL (JSON Lines) with compressed persistent indexes
|
|
64
|
+
- **Memory Strategy**: Point reading + streaming, doesn't require loading entire database
|
|
65
|
+
- **Query Language**: Advanced operators ($in, $or, $and, ranges, regex, case-insensitive)
|
|
66
|
+
- **Data Types**: string, number, boolean, array (with automatic optimization)
|
|
67
|
+
- **Indexing**: Persistent compressed indexes with term mapping for optimal performance
|
|
68
|
+
- **Transactions**: Operation queuing with manual save control (auto-save removed for better control)
|
|
69
|
+
- **Persistence**: Manual save functionality ensures data integrity and performance
|
|
70
|
+
- **File Size**: Typically 25-75% smaller than alternatives for repetitive data
|
|
71
|
+
|
|
72
|
+
## JexiDB vs Other JavaScript Databases
|
|
73
|
+
|
|
74
|
+
| Database | Pure JS | Disk Persistence | Memory Usage | Data Structure | Best Use Case |
|
|
75
|
+
|----------|---------|------------------|--------------|----------------|---------------|
|
|
76
|
+
| **JexiDB** | ✅ 100% | ✅ JSONL + Compressed Indexes | 🧠 Smart (point reading) | 📋 Schema Required | Desktop apps, Node.js with structured data |
|
|
77
|
+
| **NeDB** | ✅ 100% | ✅ JSON files | 📈 High (loads all) | 📄 Document-free | Legacy projects (unmaintained) |
|
|
78
|
+
| **Lowdb** | ✅ 100% | ✅ JSON files | 📈 High (loads all) | 📄 Document-free | Small configs, simple apps |
|
|
79
|
+
| **LokiJS** | ✅ 100% | ⚠️ Adapters only | 📈 High (in-memory primary) | 📄 Document-free | In-memory applications |
|
|
80
|
+
| **PouchDB** | ✅ 100% | ✅ IndexedDB/WebSQL | 🧠 Moderate | 📄 Document-free | Offline-first web apps |
|
|
81
|
+
| **SQLite (WASM)** | ❌ WASM required | ✅ SQLite files | 🧠 Moderate | 📊 SQL Tables | Complex relational data |
|
|
82
|
+
|
|
83
|
+
### Why Developers Choose JexiDB
|
|
84
|
+
|
|
85
|
+
**Intelligent Memory Management**: Unlike other JS databases that load entire files into memory, JexiDB uses point reading and streaming operations for unlimited dataset sizes.
|
|
86
|
+
|
|
87
|
+
**Schema Enforcement**: Provides SQL-like data structure and consistency guarantees in pure JavaScript, without the complexity of traditional databases.
|
|
88
|
+
|
|
89
|
+
**Desktop-First Architecture**: Built specifically for Electron and NW.js applications, eliminating native dependency issues that complicate desktop deployment.
|
|
90
|
+
|
|
91
|
+
**Enterprise Performance**: Combines disk persistence with in-memory query speed through compressed indexes and automatic term mapping optimization.
|
|
92
|
+
|
|
93
|
+
## Performance Benchmarks
|
|
94
|
+
|
|
95
|
+
### Memory Usage Comparison (100,000 records)
|
|
96
|
+
|
|
97
|
+
| Database | Memory Usage | Query Speed | File Size |
|
|
98
|
+
|----------|--------------|-------------|-----------|
|
|
99
|
+
| **JexiDB** | ~25MB | ~5ms (indexed) | ~15MB (compressed) |
|
|
100
|
+
| NeDB | ~80MB | ~20ms | ~45MB |
|
|
101
|
+
| Lowdb | ~120MB | ~50ms | ~60MB |
|
|
102
|
+
| LokiJS | ~90MB | ~8ms | ~35MB (adapters) |
|
|
103
|
+
|
|
104
|
+
*Benchmarks based on typical e-commerce product catalog with repetitive category/tag data*
|
|
105
|
+
|
|
106
|
+
### Size Reduction with Term Mapping
|
|
107
|
+
|
|
108
|
+
- **Without term mapping**: 45MB file size
|
|
109
|
+
- **With JexiDB term mapping**: 15MB file size
|
|
110
|
+
- **Reduction**: Up to 77% for datasets with repetitive strings
|
|
111
|
+
|
|
112
|
+
## Frequently Asked Questions
|
|
113
|
+
|
|
114
|
+
### Is JexiDB suitable for production applications?
|
|
115
|
+
|
|
116
|
+
Yes, JexiDB is production-ready with features like:
|
|
117
|
+
- Automatic data integrity recovery
|
|
118
|
+
- Transaction support with operation queuing
|
|
119
|
+
- Comprehensive error handling
|
|
120
|
+
- Active maintenance and updates
|
|
121
|
+
|
|
122
|
+
### How does JexiDB handle large datasets?
|
|
123
|
+
|
|
124
|
+
JexiDB uses **point reading** - it only loads the specific records needed for your query, not the entire database. Combined with streaming operations via `iterate()` and `walk()`, it can handle millions of records efficiently.
|
|
125
|
+
|
|
126
|
+
### Can JexiDB replace SQLite in my Electron app?
|
|
127
|
+
|
|
128
|
+
For many use cases, yes! JexiDB offers:
|
|
129
|
+
- ✅ 100% JavaScript (no native SQLite compilation issues)
|
|
130
|
+
- ✅ Schema enforcement like SQL tables
|
|
131
|
+
- ✅ Advanced queries with operators
|
|
132
|
+
- ✅ Better memory efficiency for large datasets
|
|
133
|
+
- ✅ Simpler deployment (no native binaries)
|
|
134
|
+
|
|
135
|
+
### What's the difference between fields and indexes?
|
|
136
|
+
|
|
137
|
+
**Fields** define your data structure (schema) - they're required and enforced.
|
|
138
|
+
**Indexes** optimize query performance - they're optional and should only be created for fields you query frequently.
|
|
139
|
+
|
|
140
|
+
### How does JexiDB compare to traditional databases?
|
|
141
|
+
|
|
142
|
+
JexiDB provides SQL-like structure and data consistency in pure JavaScript, but without the complexity of server setup or native dependencies. It's perfect for applications that need structured data without the overhead of full database systems.
|
|
143
|
+
|
|
144
|
+
## Quick Start - 5 Minutes to Database
|
|
145
|
+
|
|
146
|
+
### Installation
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
npm install EdenwareApps/jexidb
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Create Your First Database
|
|
153
|
+
|
|
154
|
+
```javascript
|
|
155
|
+
import { Database } from 'jexidb';
|
|
156
|
+
|
|
157
|
+
const db = new Database('users.jdb', {
|
|
158
|
+
fields: {
|
|
159
|
+
id: 'number',
|
|
160
|
+
name: 'string',
|
|
161
|
+
email: 'string',
|
|
162
|
+
role: 'string',
|
|
163
|
+
tags: 'array:string'
|
|
164
|
+
},
|
|
165
|
+
indexes: {
|
|
166
|
+
email: 'string', // Fast email lookups
|
|
167
|
+
role: 'string', // Filter by role
|
|
168
|
+
tags: 'array:string' // Search by tags
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
// Initialize and use
|
|
173
|
+
await db.init();
|
|
174
|
+
|
|
175
|
+
// Insert data
|
|
176
|
+
await db.insert({
|
|
177
|
+
id: 1,
|
|
178
|
+
name: 'John Doe',
|
|
179
|
+
email: 'john@example.com',
|
|
180
|
+
role: 'admin',
|
|
181
|
+
tags: ['developer', 'team-lead']
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
// Query data
|
|
185
|
+
const users = await db.find({ role: 'admin' });
|
|
186
|
+
const devs = await db.find({ tags: 'developer' });
|
|
187
|
+
|
|
188
|
+
// Save changes
|
|
189
|
+
await db.save();
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
**That's it!** Your data is now persisted to `users.jdb` file.
|
|
193
|
+
|
|
194
|
+
## Real-World Use Cases
|
|
195
|
+
|
|
196
|
+
### ✅ Electron Desktop Applications
|
|
197
|
+
```javascript
|
|
198
|
+
// User management in Electron app
|
|
199
|
+
const userDb = new Database('users.jdb', {
|
|
200
|
+
fields: { id: 'number', email: 'string', profile: 'object' },
|
|
201
|
+
indexes: { email: 'string' }
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
// Works offline, no server required
|
|
205
|
+
const user = await userDb.findOne({ email: 'user@example.com' });
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### ✅ Local Node.js Applications
|
|
209
|
+
```javascript
|
|
210
|
+
// Configuration storage
|
|
211
|
+
const configDb = new Database('config.jdb', {
|
|
212
|
+
fields: { key: 'string', value: 'string' },
|
|
213
|
+
indexes: { key: 'string' }
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
// Persist app settings locally
|
|
217
|
+
await configDb.insert({ key: 'theme', value: 'dark' });
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### ✅ Data Processing Scripts
|
|
221
|
+
```javascript
|
|
222
|
+
// Process large CSV files
|
|
223
|
+
const dataDb = new Database('processed.jdb', {
|
|
224
|
+
fields: { id: 'number', data: 'object' }
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
// Handle millions of records efficiently
|
|
228
|
+
for await (const record of dataDb.iterate({ processed: false })) {
|
|
229
|
+
// Process record
|
|
230
|
+
record.processed = true;
|
|
231
|
+
record.timestamp = Date.now();
|
|
232
|
+
}
|
|
233
|
+
await dataDb.save();
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### ✅ NW.js Applications
|
|
237
|
+
```javascript
|
|
238
|
+
// Product catalog for desktop POS system
|
|
239
|
+
const productsDb = new Database('products.jdb', {
|
|
240
|
+
fields: {
|
|
241
|
+
sku: 'string',
|
|
242
|
+
name: 'string',
|
|
243
|
+
price: 'number',
|
|
244
|
+
category: 'string',
|
|
245
|
+
tags: 'array:string'
|
|
246
|
+
},
|
|
247
|
+
indexes: {
|
|
248
|
+
sku: 'string',
|
|
249
|
+
category: 'string',
|
|
250
|
+
tags: 'array:string'
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
## Perfect Use Cases for JexiDB
|
|
256
|
+
|
|
257
|
+
### ✅ Ideal For:
|
|
258
|
+
- **Desktop Applications** (Electron, NW.js, Tauri) - No native dependency issues
|
|
259
|
+
- **Local Node.js Applications** - Simple deployment without database servers
|
|
260
|
+
- **Offline-First Apps** - Works completely offline with local persistence
|
|
261
|
+
- **Data Processing Scripts** - Handle large datasets with streaming operations
|
|
262
|
+
- **Configuration Storage** - Simple key-value storage with schema validation
|
|
263
|
+
- **Prototyping** - Quick setup with real persistence and advanced queries
|
|
264
|
+
|
|
265
|
+
### ❌ Less Ideal For:
|
|
266
|
+
- **Multi-user web applications** - Use database servers instead
|
|
267
|
+
- **Heavy concurrent writes** - JexiDB is single-writer optimized
|
|
268
|
+
- **Complex relational data** - Consider traditional SQL databases
|
|
269
|
+
- **Browser-only applications** - Use IndexedDB/PouchDB for web
|
|
270
|
+
|
|
271
|
+
## Bulk Operations with `iterate()`
|
|
272
|
+
|
|
273
|
+
The `iterate()` method provides high-performance bulk update capabilities with streaming support:
|
|
274
|
+
|
|
275
|
+
```javascript
|
|
276
|
+
// Basic bulk update
|
|
277
|
+
for await (const product of db.iterate({ category: 'electronics' })) {
|
|
278
|
+
product.price = product.price * 1.1; // 10% increase
|
|
279
|
+
product.updatedAt = new Date().toISOString();
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// With progress tracking
|
|
283
|
+
for await (const item of db.iterate(
|
|
284
|
+
{ status: 'active' },
|
|
285
|
+
{
|
|
286
|
+
chunkSize: 1000,
|
|
287
|
+
progressCallback: (progress) => {
|
|
288
|
+
console.log(`Processed: ${progress.processed}, Modified: ${progress.modified}`);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
)) {
|
|
292
|
+
item.processed = true;
|
|
293
|
+
}
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
**Benefits:**
|
|
297
|
+
- **Streaming Performance**: Process large datasets without loading everything into memory
|
|
298
|
+
- **Bulk Updates**: Modify multiple records in a single operation
|
|
299
|
+
- **Automatic Change Detection**: Automatically detects modified records
|
|
300
|
+
- **Progress Tracking**: Optional progress callbacks for long-running operations
|
|
301
|
+
|
|
302
|
+
## Advanced Queries
|
|
303
|
+
|
|
304
|
+
```javascript
|
|
305
|
+
// Multiple conditions (automatic AND)
|
|
306
|
+
const results = await db.find({
|
|
307
|
+
age: { '>': 18, '<': 65 },
|
|
308
|
+
status: 'active',
|
|
309
|
+
category: { '$in': ['premium', 'vip'] }
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
// Logical operators
|
|
313
|
+
const complex = await db.find({
|
|
314
|
+
'$or': [
|
|
315
|
+
{ type: 'admin' },
|
|
316
|
+
{ '$and': [
|
|
317
|
+
{ type: 'user' },
|
|
318
|
+
{ verified: true }
|
|
319
|
+
]}
|
|
320
|
+
]
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
// Arrays
|
|
324
|
+
const withTags = await db.find({
|
|
325
|
+
tags: 'javascript', // Contains 'javascript'
|
|
326
|
+
tags: { '$all': ['js', 'node'] } // Contains all values
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
// Coverage analysis with filtering
|
|
330
|
+
const liveCoverage = await db.coverage('tags', [
|
|
331
|
+
{ terms: ['javascript'], excludes: [] },
|
|
332
|
+
{ terms: ['react', 'vue'], excludes: ['angular'] }
|
|
333
|
+
], { mediaType: 'live' }) // Only analyze live content
|
|
334
|
+
|
|
335
|
+
// Multi-value filtering (OR logic)
|
|
336
|
+
const multiTypeCoverage = await db.coverage('tags', [
|
|
337
|
+
{ terms: ['tutorial'] }
|
|
338
|
+
], { mediaType: ['live', 'vod'] }) // Live OR VOD content
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
## Testes
|
|
342
|
+
|
|
343
|
+
JexiDB inclui uma suíte completa de testes com Jest:
|
|
344
|
+
|
|
345
|
+
```bash
|
|
346
|
+
npm test # Executa todos os testes
|
|
347
|
+
npm run test:watch # Modo watch para desenvolvimento
|
|
348
|
+
npm run test:coverage # Relatório de cobertura
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
## 📚 Documentation
|
|
352
|
+
|
|
353
|
+
- **[📖 Full Documentation](docs/README.md)** - Complete documentation index
|
|
354
|
+
- **[🔧 API Reference](docs/API.md)** - Detailed API documentation
|
|
355
|
+
- **[💡 Examples](docs/EXAMPLES.md)** - Practical examples and use cases
|
|
356
|
+
- **[🚀 Getting Started](docs/README.md#quick-start)** - Quick start guide
|
|
357
|
+
|
|
358
|
+
## Migration Guide
|
|
359
|
+
|
|
360
|
+
### Coming from Other Databases
|
|
361
|
+
|
|
362
|
+
#### From NeDB/Lowdb
|
|
363
|
+
```javascript
|
|
364
|
+
// Before (NeDB)
|
|
365
|
+
const Datastore = require('nedb');
|
|
366
|
+
const db = new Datastore({ filename: 'data.db' });
|
|
367
|
+
|
|
368
|
+
// After (JexiDB)
|
|
369
|
+
import { Database } from 'jexidb';
|
|
370
|
+
const db = new Database('data.jdb', {
|
|
371
|
+
fields: { /* define your schema */ },
|
|
372
|
+
indexes: { /* define indexes */ }
|
|
373
|
+
});
|
|
374
|
+
await db.init(); // Required!
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
#### From SQLite
|
|
378
|
+
```javascript
|
|
379
|
+
// SQLite requires native compilation
|
|
380
|
+
const sqlite3 = require('sqlite3').verbose();
|
|
381
|
+
const db = new sqlite3.Database('data.db');
|
|
382
|
+
|
|
383
|
+
// JexiDB - pure JavaScript, no compilation
|
|
384
|
+
import { Database } from 'jexidb';
|
|
385
|
+
const db = new Database('data.jdb', { /* config */ });
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
#### From LocalStorage/IndexedDB
|
|
389
|
+
```javascript
|
|
390
|
+
// Browser storage limitations
|
|
391
|
+
localStorage.setItem('data', JSON.stringify(largeDataset));
|
|
392
|
+
|
|
393
|
+
// JexiDB - true file persistence
|
|
394
|
+
const db = new Database('data.jdb', { /* config */ });
|
|
395
|
+
await db.insert(largeDataset);
|
|
396
|
+
await db.save();
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
## Community & Support
|
|
400
|
+
|
|
401
|
+
### Get Help
|
|
402
|
+
- 📖 **[Full Documentation](docs/README.md)** - Complete guides and API reference
|
|
403
|
+
- 💬 **[GitHub Issues](https://github.com/EdenwareApps/jexidb/issues)** - Bug reports and feature requests
|
|
404
|
+
- 💡 **[Examples](docs/EXAMPLES.md)** - Real-world usage patterns
|
|
405
|
+
|
|
406
|
+
### Contributing
|
|
407
|
+
Found a bug or want to contribute? We welcome pull requests!
|
|
408
|
+
|
|
409
|
+
1. Fork the repository
|
|
410
|
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
411
|
+
3. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
412
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
413
|
+
5. Open a Pull Request
|
|
414
|
+
|
|
415
|
+
### License
|
|
416
|
+
MIT License - see the [LICENSE](LICENSE) file for details.
|
|
417
|
+
|
|
418
|
+
## What's Next - Roadmap
|
|
419
|
+
|
|
420
|
+
### Planned Features
|
|
421
|
+
- 🚀 **SQL-like Query Builder** - More intuitive query construction
|
|
422
|
+
- 📊 **Built-in Aggregation Functions** - Count, sum, average operations
|
|
423
|
+
- 🔐 **Encryption Support** - Optional data encryption at rest
|
|
424
|
+
- 📱 **React Native Support** - Mobile database capabilities
|
|
425
|
+
- 🌐 **Multi-threading** - Better concurrent operation handling
|
|
426
|
+
- 📈 **Advanced Analytics** - Built-in data analysis tools
|
|
427
|
+
|
|
428
|
+
### Recent Updates
|
|
429
|
+
- ✅ **v2.1.0** - Term mapping auto-detection, 77% size reduction
|
|
430
|
+
- ✅ **Schema Enforcement** - Mandatory fields for data consistency
|
|
431
|
+
- ✅ **Streaming Operations** - Memory-efficient bulk operations
|
|
432
|
+
- ✅ **Compressed Indexes** - Persistent indexing with compression
|
|
433
|
+
|
|
434
|
+
---
|
|
435
|
+
|
|
436
|
+
<p align="center">
|
|
437
|
+
<img width="380" src="https://edenware.app/jexidb/images/jexidb-mascot3.jpg" alt="JexiDB mascot - JavaScript EXtended Intelligent DataBase for desktop applications" title="JexiDB - JavaScript EXtended Intelligent DataBase mascot" />
|
|
438
|
+
</p>
|
|
439
|
+
|
|
440
|
+
## Support the Project
|
|
441
|
+
|
|
442
|
+
If JexiDB helps your project, consider supporting its development:
|
|
443
|
+
|
|
444
|
+
- ⭐ **Star on GitHub** - Show your support
|
|
445
|
+
- 🐛 **Report Issues** - Help improve stability
|
|
446
|
+
- 💝 **Donate** - [PayPal](https://www.paypal.com/donate/?item_name=megacubo.tv&cmd=_donations&business=efox.web%40gmail.com)
|
|
447
|
+
|
|
448
|
+
**The Only Pure JS Database with Smart Disk Persistence & Intelligent Memory Management**
|
|
449
|
+
|
|
450
|
+
**Built with ❤️ for the JavaScript community**
|
|
451
|
+
|
|
452
|
+
---
|
|
453
|
+
|
|
454
|
+
---
|
|
455
|
+
|
|
456
|
+
## Links & Resources
|
|
457
|
+
|
|
458
|
+
- **📦 NPM Package**: [npmjs.com/package/jexidb](https://www.npmjs.com/package/jexidb)
|
|
459
|
+
- **📚 Documentation**: [docs/README.md](docs/README.md)
|
|
460
|
+
- **💬 Issues**: [github.com/EdenwareApps/jexidb/issues](https://github.com/EdenwareApps/jexidb/issues)
|