# @edonec/indexed-db-class

to install

type

```bash
yarn add @edonec/indexed-db-class
```

or

```bash
npm install @edonec/indexed-db-class
```

## Usage

init the Class like so

```js
let db: IndexedDb;

// for SSR make sure the window is defined
if (typeof window !== 'undefined') {
  db = new IndexedDb('Auth', [{ tableName: 'user', key: 'id' }]);
}

export { db };
```

and then make use of the functions within the `db` object

```js
// creatinga new table
await db.createTable('address', 'id');

// adding data to an existing table
await db.postData('address', {
  /* ...some data */
});
// update existing data to an existing table or create it if not existe
await db.createOrUpdate('address', {
  /* ...some data */
});
// update existing data to an existing table
await db.updateData('address', {
  /* ...some data */
});
// delete a record from an existing table
db.deleteData('address', id);

// getting data
const data = (await db.getData) < string > ('user', 'some id that you previously sat');
```
