1.0.7 • Published 4 years ago

@edonec/indexed-db-class v1.0.7

Weekly downloads
-
License
ISC
Repository
gitlab
Last release
4 years ago

@edonec/indexed-db-class

to install

type

yarn add @edonec/indexed-db-class

or

npm install @edonec/indexed-db-class

Usage

init the Class like so

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

// 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');
1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago