More fun with web workers...
This commit is contained in:
1 parent
94de17938e
commit
ebf4f39331
5 files changed
+38
-10
No files matched your search
+18
-2
@@ -1,6 +1,10 @@
|
||||
import _ from 'lodash';
|
||||
import PouchDB from 'pouchdb';
|
||||
import PouchDBFind from 'pouchdb-find';
|
||||
import uri from '../lib/ids';
|
||||
|
||||
PouchDB.plugin(PouchDBFind);
|
||||
|
||||
const dbDefinitionId = uri('dbdef', {});
|
||||
|
||||
const currentDbDefinition = {
|
||||
@@ -9,7 +13,19 @@ const currentDbDefinition = {
|
||||
def: { version: '0.000001' },
|
||||
};
|
||||
|
||||
export const initDb = async (db: any, setDbReady?: any) => {
|
||||
declare global {
|
||||
var db: any;
|
||||
var dbReady: boolean;
|
||||
}
|
||||
|
||||
export const initDb = async (params: any) => {
|
||||
if (globalThis.db === undefined) {
|
||||
globalThis.db = new PouchDB('dyomedea', {
|
||||
auto_compaction: true,
|
||||
revs_limit: 10,
|
||||
});
|
||||
}
|
||||
const db = globalThis.db;
|
||||
var previousDbDefinition = {
|
||||
_id: dbDefinitionId,
|
||||
type: dbDefinitionId,
|
||||
@@ -81,7 +97,7 @@ export const initDb = async (db: any, setDbReady?: any) => {
|
||||
}
|
||||
}
|
||||
|
||||
if (setDbReady !== undefined) setDbReady(true);
|
||||
globalThis.dbReady = true;
|
||||
|
||||
/* const indexes = await db.getIndexes();
|
||||
console.log(`indexes: ${JSON.stringify(indexes)}`);
|
||||
|
||||
Reference in new issue
Block a user