# open-store

> open-store

Latest version **1.0.0** (published 2022-07-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install open-store
pnpm add open-store
yarn add open-store
bun add open-store
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2022-07-11 |
| First published | 2022-07-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 26 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | cenfun |

## Links

- npm: https://www.npmjs.com/package/open-store
- Repository: https://github.com/cenfun/open-store
- Homepage: https://github.com/cenfun/open-store#readme
- Issues: https://github.com/cenfun/open-store/issues
- npm.io page: https://npm.io/package/open-store

## Recent versions

- 1.0.0 (latest) — 2022-07-11

## README

# open-store
open-store is promised store implemented with IndexedDB.

## Install
```sh
npm i open-store
```
## Usage
```js
import { openStore } from "open-store";

const ost = await openStore();

await ost.set('my-key', 'my-value');
const v = await ost.get('my-key');
console.assert(v === 'my-value');

```

## With custom db name and store name
```js
const ost = await openStore("dbName", "storeName");
```

## With store options
```js
//keyPath is "id"
const ost = await openStore("dbName", "storeName", "id");
//autoIncrement
const ost = await openStore("dbName", "storeName", true);
//or both
const ost = await openStore("dbName", "storeName", {
    keyPath: "id",
    autoIncrement: true
});
```

## With index options
```js
const ost = await openStore("dbName", "storeName", {
    index: {
        id: {
            unique: true
        },
        name: {
            unique: false
        }
    }
});

// get value by index name
const v = await ost.get('Tom And Jerry', 'name');
```

## API
```js
// global
import { getDBs, deleteDB, openStore } from "open-store";
getDBs()
deleteDB(dbName)
openStore(dbName = 'db', storeName = 'store', options = {})

// data
ost.add(value, key)
ost.put(value, key)
ost.delete(key)
ost.set(key, value)
ost.get(key, indexKey)
ost.getAll(query, count)
ost.each(handler)
ost.count()
ost.clear()

// store
ost.hasStore(storeName)
ost.deleteStore(storeName)
ost.createStore(storeName, options)
ost.useStore(storeName)
ost.getStoreNames()

// db
ost.close()
```

more example: [public/index.html](public/index.html)

---
_Source: https://npm.io/package/open-store · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
