diff --git a/src/indexed-db.ts b/src/indexed-db.ts index 6883806..c6fe3bc 100644 --- a/src/indexed-db.ts +++ b/src/indexed-db.ts @@ -1,39 +1,5 @@ import { openDB, IDBPDatabase, unwrap } from "idb/index.js" -export class IDBCursorValueIterator { - cursor: IDBCursorWithValue - - constructor(cursor: IDBCursorWithValue) { - this.cursor = cursor - } - - next(): IteratorResult { - const key = this.cursor.key - const value = this.cursor.value - let done = false - - try { - this.cursor.continue() - } - catch (error) { - if (error.name === "InvalidStateError") { - done = true - } - else { - throw error - } - } - finally { - return { value: {key: key, value: value}, done: done } - } - } - - [Symbol.iterator]() { - return this - } - -} - export class CheckCache { slopdb: IDBPDatabase cache_capacity: number @@ -82,13 +48,22 @@ export class CheckCache { } } +export class SlopStore { + slopdb: IDBPDatabase + static slop_objectstore_name = "slop" + + constructor(slopdb: IDBPDatabase) { + this.slopdb = slopdb + } +} + export class SlopDB { version: number open_promise: Promise db: IDBPDatabase - // slop_store: SlopStore check_cache: CheckCache + slop_store: SlopStore static apply_db_upgrade(db: IDBPDatabase, idb_version: number) { switch (idb_version) { @@ -121,6 +96,9 @@ export class SlopDB { this.db = db // create a CheckCache object to handle the check_cache object store this.check_cache = new CheckCache(this.db, 512) + + // create a SlopStore object to handle the slop object store + this.slop_store = new SlopStore(this.db) }) }