Nightly Piano Man

    @tatchi/bs-idb-keyval

    0.2.0 • Public • Published

    bs-idb-keyval

    BuckleScript bindings for idb-keyval

    Installation

    npm install --save @tatchi/bs-idb-keyval

    Then add @tatchi/bs-idb-keyval to bs-dependencies in your bsconfig.json:

    {
      ...
      "bs-dependencies": ["@tatchi/bs-idb-keyval"]
    }

    Usage

    Create store:

    let store = IdbKeyVal.createStore("custom-db-name", "custom-store-name");

    set:

    IdbKeyVal.set("key", "value", store)
      |> Js.Promise.then_(() => {
           Js.log("It worked!");
           Js.Promise.resolve();
         })
      |> Js.Promise.catch(err => {
           Js.log2("It failed!!", err);
           Js.Promise.resolve();
         });

    get:

    IdbKeyVal.get("key", store)
    |> Js.Promise.then_(value => {
         // logs: "value"
         Js.log(value);
         Js.Promise.resolve();
       });

    keys:

    IdbKeyVal.keys(store)
    |> Js.Promise.then_(keys => {
         // logs: ["key"]
         Js.log(keys);
         Js.Promise.resolve();
       });

    delete:

    IdbKeyVal.delete("key", store)
    |> Js.Promise.then_(keys => {
         Js.log("deleted");
         Js.Promise.resolve();
       });

    clear:

    IdbKeyVal.clear(store)
    |> Js.Promise.then_(keys => {
         Js.log("cleared");
         Js.Promise.resolve();
       });

    Install

    npm i @tatchi/bs-idb-keyval

    DownloadsWeekly Downloads

    2

    Version

    0.2.0

    License

    MIT

    Unpacked Size

    4.21 kB

    Total Files

    6

    Last publish

    Collaborators

    • tatchi