new SimpleDB(dbNameopt, tableNameopt)
- Description:
A simple indexedDB handler to store LocalStorage like key value pair... except, it is better.
The benefits are:- Can store large amount of data.
- Asynchronous and non-blocking.
- Loaded on demand unlike LocalStorage.
- Can store JavaScript object data.
- Source:
Example
var myStorage = new DB();
//store a value to "someKey"
await myStorage.set("someKey", {"someObject" : "with the value"}):
//get the value of "someKey"
await myStorage.get("someKey");
// will returns:
{
"someObject": "with the value"
}
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
dbName |
String |
<optional> |
commonDB
|
The DB name |
tableName |
String |
<optional> |
keyValuePairs
|
Table name |
Methods
clear() → {Promise.<Event>}
- Description:
Clear a database.
- Source:
Returns:
- Transaction event
- Type
- Promise.<Event>
(async) delete(key) → {Promise.<Event>}
- Description:
Delete a record from local DB.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
key |
String | key of the key-value pair |
Returns:
- Transaction event
- Type
- Promise.<Event>
(async) get(key) → {Promise.<*>}
- Description:
Get a value from local DB.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
key |
String | key of the key-value pair |
Returns:
- The value
- Type
- Promise.<*>
(async) set(key, value) → {Promise.<Event>}
- Description:
Set a value to the local DB
- Source:
Parameters:
Name | Type | Description |
---|---|---|
key |
String | key of the key-value pair |
value |
* | Value of the key-value pair. Value can be anything. Unlike LocalStorage, if you can also store object in the DB. |
Returns:
- Transaction event
- Type
- Promise.<Event>