@live-change/db 0.8.2 → 0.8.3
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/lib/AtomicWriter.js +1 -0
- package/lib/Database.js +7 -2
- package/lib/Index.js +17 -10
- package/lib/Table.js +2 -0
- package/package.json +4 -4
package/lib/AtomicWriter.js
CHANGED
package/lib/Database.js
CHANGED
|
@@ -278,12 +278,17 @@ class Database {
|
|
|
278
278
|
return queryObservable.single(this, code)
|
|
279
279
|
}
|
|
280
280
|
|
|
281
|
-
handleUnhandledRejectionInIndex(name, reason
|
|
281
|
+
handleUnhandledRejectionInIndex(name, reason) {
|
|
282
282
|
const config = this.config.indexes[name]
|
|
283
283
|
console.error("INDEX", name, "unhandledRejection", reason, "CODE:\n", config?.code)
|
|
284
284
|
console.error("DELETING INDEX", name)
|
|
285
|
+
const index = this.indexes.get(name)
|
|
286
|
+
if(index) {
|
|
287
|
+
index.deleteIndex()
|
|
288
|
+
this.indexes.delete(name)
|
|
289
|
+
}
|
|
285
290
|
nextTick(() => {
|
|
286
|
-
if(!config) {
|
|
291
|
+
if(!this.config.indexes[name]) {
|
|
287
292
|
console.error("INDEX", name, "IS ALREADY DELETED")
|
|
288
293
|
console.trace("ALREADY DELETED")
|
|
289
294
|
return;
|
package/lib/Index.js
CHANGED
|
@@ -135,7 +135,6 @@ class TableReader extends ChangeStream {
|
|
|
135
135
|
for(const rangeReader of rangeReaders) {
|
|
136
136
|
rangeReader.change(obj, oldObj, id, timestamp)
|
|
137
137
|
}
|
|
138
|
-
//console.log("TR change", this.callbacks[0])
|
|
139
138
|
for(const callback of this.callbacks) await callback(obj, oldObj, id, timestamp)
|
|
140
139
|
if(profileOp) await profileLog.end(profileOp)
|
|
141
140
|
}
|
|
@@ -372,16 +371,20 @@ class OpLogReader {
|
|
|
372
371
|
//console.log("CKN", this.currentKey, '=>', next.key)
|
|
373
372
|
this.currentKey = next.key
|
|
374
373
|
//console.log("READ TO", readEnd)
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
if(
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
374
|
+
try {
|
|
375
|
+
const readKey = await next.reader.readTo(readEnd)
|
|
376
|
+
//console.log("READED")
|
|
377
|
+
if(readKey) {
|
|
378
|
+
if((readKey||'') < this.currentKey) {
|
|
379
|
+
//debugger
|
|
380
|
+
console.error("time travel", readKey, this.currentKey)
|
|
381
|
+
//process.exit(1) /// TODO: do something about it!
|
|
382
|
+
}
|
|
383
|
+
//console.log("CKR", this.currentKey, '=>', readKey)
|
|
384
|
+
this.currentKey = readKey
|
|
382
385
|
}
|
|
383
|
-
|
|
384
|
-
this.
|
|
386
|
+
} catch(error) {
|
|
387
|
+
this.database.handleUnhandledRejectionInIndex(this.indexName, error)
|
|
385
388
|
}
|
|
386
389
|
}
|
|
387
390
|
} while(this.gotSignals)
|
|
@@ -400,9 +403,13 @@ class IndexWriter {
|
|
|
400
403
|
this.index = index
|
|
401
404
|
}
|
|
402
405
|
put(object) {
|
|
406
|
+
const id = object.id
|
|
407
|
+
if(!id) throw new Error(`ID is empty ${JSON.stringify(object)}`)
|
|
403
408
|
this.index.put(object)
|
|
404
409
|
}
|
|
405
410
|
delete(object) {
|
|
411
|
+
const id = object.id
|
|
412
|
+
if(!id) throw new Error(`ID is empty ${JSON.stringify(object)}`)
|
|
406
413
|
this.index.delete(object.id)
|
|
407
414
|
}
|
|
408
415
|
update(id, ops) {
|
package/lib/Table.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/db",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.3",
|
|
4
4
|
"description": "Database with observable data for live queries",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"type": "module",
|
|
23
23
|
"homepage": "https://github.com/live-change/live-change-db",
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@live-change/db-store-level": "^0.8.
|
|
26
|
-
"@live-change/db-store-lmdb": "^0.8.
|
|
25
|
+
"@live-change/db-store-level": "^0.8.3",
|
|
26
|
+
"@live-change/db-store-lmdb": "^0.8.3",
|
|
27
27
|
"minimist": ">=1.2.3",
|
|
28
28
|
"next-tick": "^1.1.0",
|
|
29
29
|
"rimraf": "^5.0.5",
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"get-random-values": "^1.2.2",
|
|
37
37
|
"node-interval-tree": "^1.3.3"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "81b4ac5a36ab1abdf9d521e3c4fbea6d194bb892"
|
|
40
40
|
}
|