Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tatchi/bs-idb-keyval
BuckleScript bindings for idb-keyval
https://github.com/tatchi/bs-idb-keyval
buscklescript idb-keyval indexeddb javascript reasonml
Last synced: about 2 months ago
JSON representation
BuckleScript bindings for idb-keyval
- Host: GitHub
- URL: https://github.com/tatchi/bs-idb-keyval
- Owner: tatchi
- License: mit
- Created: 2019-07-26T13:51:10.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-04-25T21:51:26.000Z (over 4 years ago)
- Last Synced: 2024-11-07T14:06:54.455Z (2 months ago)
- Topics: buscklescript, idb-keyval, indexeddb, javascript, reasonml
- Language: Reason
- Homepage:
- Size: 66.4 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# bs-idb-keyval
[BuckleScript](https://github.com/bucklescript/bucklescript) bindings for [idb-keyval](https://github.com/jakearchibald/idb-keyval)
## Installation
```sh
npm install --save @tatchi/bs-idb-keyval
```Then add `@tatchi/bs-idb-keyval` to `bs-dependencies` in your `bsconfig.json`:
```js
{
...
"bs-dependencies": ["@tatchi/bs-idb-keyval"]
}
```## Usage
### Create store:
```js
let store = IdbKeyVal.createStore("custom-db-name", "custom-store-name");
```### set:
```js
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:
```js
IdbKeyVal.get("key", store)
|> Js.Promise.then_(value => {
// logs: "value"
Js.log(value);
Js.Promise.resolve();
});
```### keys:
```js
IdbKeyVal.keys(store)
|> Js.Promise.then_(keys => {
// logs: ["key"]
Js.log(keys);
Js.Promise.resolve();
});
```### delete:
```js
IdbKeyVal.delete("key", store)
|> Js.Promise.then_(keys => {
Js.log("deleted");
Js.Promise.resolve();
});
```### clear:
```js
IdbKeyVal.clear(store)
|> Js.Promise.then_(keys => {
Js.log("cleared");
Js.Promise.resolve();
});
```