@live-change/db
Advanced tools
Comparing version 0.3.27 to 0.3.28
@@ -129,2 +129,3 @@ function getProperty(of, propertyName) { | ||
this.id = id | ||
if(typeof id != 'string') throw new Error(`ID is not string: ${JSON.stringify(id)}`) | ||
this.readPromise = null | ||
@@ -145,2 +146,3 @@ this.writePromise = null | ||
async put(object) { | ||
if(typeof object.id != 'string') throw new Error(`ID is not string: ${JSON.stringify(id)}`) | ||
this.operations = [] | ||
@@ -200,2 +202,3 @@ if(this.writePromise) await this.writePromise | ||
this.operations = [] | ||
//console.log("PUT UPDATED", value) | ||
if(value) await this.put(value) | ||
@@ -242,3 +245,3 @@ //console.log("UPDATE WRITTEN", this.id, this.operations) | ||
put(object) { | ||
async put(object) { | ||
const id = object.id | ||
@@ -250,3 +253,3 @@ let queue = this.writes.get(id) | ||
} | ||
return queue.put(object) | ||
return await queue.put(object) | ||
} | ||
@@ -264,2 +267,3 @@ | ||
update(id, operations, options) { | ||
if(typeof id != 'string') throw new Error(`ID is not string: ${JSON.stringify(id)}`) | ||
let queue = this.writes.get(id) | ||
@@ -266,0 +270,0 @@ if(!queue) { |
@@ -77,2 +77,3 @@ const IntervalTree = require('node-interval-tree').default | ||
const id = obj ? obj.id : oldObj.id | ||
if(typeof id != 'string') throw new Error(`ID is not string: ${JSON.stringify(id)}`) | ||
const objectReader = this.objectReaders.get(id) | ||
@@ -309,2 +310,8 @@ if(objectReader) objectReader.change(obj, oldObj) | ||
update(id, ops) { | ||
if(typeof id != 'string') { | ||
console.error("Index update id is corrupted", JSON.stringify(id)) | ||
console.error("INDEX", this.index.name) | ||
console.error("INDEX CODE", this.index.codeObservable.value) | ||
console.error("INDEX PARAMS", this.index.params) | ||
} | ||
this.index.update(id, ops) | ||
@@ -341,2 +348,3 @@ } | ||
this.codeObservable = new ReactiveDao.ObservableValue(code) | ||
this.params = params | ||
this.scriptContext = new ScriptContext({ | ||
@@ -343,0 +351,0 @@ /// TODO: script available routines |
@@ -32,2 +32,3 @@ | ||
async put(object) { | ||
if(typeof object.id != 'string') throw new Error(`ID is not string: ${JSON.stringify(id)}`) | ||
let res = await this.store.put(object) | ||
@@ -34,0 +35,0 @@ if(JSON.stringify(object) == JSON.stringify(res)) return res |
@@ -17,3 +17,3 @@ const OpLogger = require('./OpLogger.js') | ||
const id = ((''+lastTime).padStart(16, '0'))+':'+((''+lastId).padStart(6, '0')) | ||
store.put({ id, timestamp:lastTime, operation }) | ||
store.put({ id, timestamp: lastTime, operation }) | ||
return id | ||
@@ -56,4 +56,10 @@ } | ||
put(object) { | ||
return this.atomicWriter.put(object) | ||
async put(object) { | ||
try { | ||
return await this.atomicWriter.put(object) | ||
} catch(e) { | ||
console.error("ERROR WHILE PUTTING OBJECT", object.id, "TO TABLE", this.name) | ||
console.error(e) | ||
throw e | ||
} | ||
} | ||
@@ -66,2 +72,3 @@ | ||
update(id, operations, options) { | ||
if(typeof id != 'string') throw new Error(`ID is not string: ${JSON.stringify(id)}`) | ||
return this.atomicWriter.update(id, operations, options) | ||
@@ -68,0 +75,0 @@ } |
{ | ||
"name": "@live-change/db", | ||
"version": "0.3.27", | ||
"version": "0.3.28", | ||
"description": "Database with observable data for live queries", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
78883
2368