UNPKG

@ocap/indexdb-memory

Version:

OCAP indexdb adapter that uses memory as backend, just for test purpose

38 lines (36 loc) 1.61 kB
import { name, version } from "../package.mjs"; import base_default from "../table/base.mjs"; import transaction_default from "../table/transaction.mjs"; import base_default$1 from "./base.mjs"; import { md5 } from "@ocap/util/lib/md5"; import Lokijs from "lokijs"; //#region src/db/index.ts let instanceCounter = 0; var MemoryIndexDB = class extends base_default$1 { constructor() { super(); this.name = name; this.version = version; this.md5 = md5; instanceCounter += 1; this.db = new Lokijs(`ocap-memory-indexdb-${instanceCounter}.db`); this.account = new base_default("account", "address", this.db); this.asset = new base_default("asset", "address", this.db); this.delegation = new base_default("delegation", "address", this.db); this.tx = new transaction_default("tx", "hash", this.db); this.factory = new base_default("factory", "address", this.db); this.token = new base_default("token", "address", this.db); this.stake = new base_default("stake", "address", this.db); this.rollup = new base_default("rollup", "address", this.db); this.rollupBlock = new base_default("rollupBlock", "hash", this.db); this.rollupValidator = new base_default("rollupValidator", "address", this.db); this.tokenDistribution = new base_default("tokenDistribution", "tokenAddress", this.db); this.balance = new base_default("balance", ["address", "tokenAddress"], this.db); this.tokenFactory = new base_default("tokenFactory", "address", this.db); this.attachReadyListeners(); } async close() {} }; var db_default = MemoryIndexDB; //#endregion export { db_default as default };