2020-11-26 16:29:10 +11:00
|
|
|
import * as Comlink from "comlink";
|
|
|
|
|
|
|
|
|
|
import { getDatabase } from "../database";
|
|
|
|
|
|
|
|
|
|
// Worker to load large amounts of database data on a separate thread
|
|
|
|
|
let obj = {
|
|
|
|
|
data: [],
|
|
|
|
|
async loadData(table) {
|
|
|
|
|
this.data = [];
|
2020-11-26 17:08:09 +11:00
|
|
|
try {
|
|
|
|
|
let db = getDatabase({});
|
|
|
|
|
// Use a cursor instead of toArray to prevent IPC max size error
|
|
|
|
|
await db.table(table).each((map) => this.data.push(map));
|
|
|
|
|
} catch {}
|
2020-11-26 16:29:10 +11:00
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Comlink.expose(obj);
|