indexeddb_wrapper_far
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

indexeddb_wrapper

Simplified operation of indexedDB and support for Promise

sample

install

yarn add indexeddb_wrapper_far
interface SampleTable {
  date: string;
}

class SampleDatabase extends DatabaseScriptsBase<SampleTable> {
  public keyPath: string = "database/sample";

  constructor(storeName: "sample", mode: IDBTransactionMode) {
    super(storeName, mode);
  }

}

document.getElementById("init")!.addEventListener("click", async () => {
  const db = new SampleDatabase("sample", "readwrite");
  await db.initialize({ keyPath: db.keyPath, data: [] });
  await db.get(db.keyPath);
});

document.getElementById("add")!.addEventListener("click", async () => {
  const db = new SampleDatabase("sample", "readwrite");
  await db.put({
    keyPath: db.keyPath,
    data: [
      { date: new Date().getTime().toString() },
      { date: new Date().getTime().toString() + 1 }
    ]
  });
});

Readme

Keywords

none

Package Sidebar

Install

npm i indexeddb_wrapper_far

Weekly Downloads

0

Version

0.0.3

License

none

Unpacked Size

15.7 kB

Total Files

7

Last publish

Collaborators

  • ymuichiro