@live-change/db
Advanced tools
Comparing version 0.3.25 to 0.3.26
const { TableWriter, LogWriter } = require('./queryUpdate.js') | ||
const maxGetLimit = 256 | ||
class ObjectReader { | ||
@@ -46,4 +48,16 @@ #table = null | ||
async onChange(cb) { | ||
let objects = await (await this.#table).rangeGet({}) | ||
await Promise.all(objects.map(object => cb(object, null))) | ||
let results = [] | ||
let objects = [] | ||
let range = { limit: maxGetLimit } | ||
while(true) { | ||
objects = await (await this.#table).rangeGet(range) | ||
results = results.concat(await Promise.all(objects.map(object => cb(object, null)))) | ||
if(objects.length == maxGetLimit) { | ||
range.gt = objects[objects.length - 1].id | ||
console.log("GET LIMIT REACHED! GETTING MORE", range) | ||
} else { | ||
break // all processed | ||
} | ||
} | ||
return results | ||
} | ||
@@ -50,0 +64,0 @@ unobserve(obs) {} |
{ | ||
"name": "@live-change/db", | ||
"version": "0.3.25", | ||
"version": "0.3.26", | ||
"description": "Database with observable data for live queries", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
77664
2346