Helper function to create a transaction and object store.
Parameter | Type | Description |
---|---|---|
db |
IDBDatabase |
The indexedDB database. |
loc |
string |
The location or name of the object store. |
type |
string , optional |
The type of transaction (default is 'readwrite'). |
Returns: An object containing the transaction and object store.
Helper function to create an IDBKeyRange based on the provided options.
Parameter | Type | Description |
---|---|---|
o |
Object |
Options object containing lt, gt, lte, and gte properties. |
Returns: An IDBKeyRange
object.
Class representing an IndexedDB wrapper.
Constructor for the Indexed class.
Parameter | Type | Description |
---|---|---|
loc |
string |
The location or name of the object store. |
Static method to open an IndexedDB database.
Parameter | Type | Description |
---|---|---|
...args |
...* |
Arguments passed to the constructor. |
Returns: A promise resolving to an instance of the Indexed class.
Static method to delete an IndexedDB database.
Parameter | Type | Description |
---|---|---|
loc |
string |
The location or name of the object store. |
Returns: A promise resolving to an object with data or error information.
Initializes the IndexedDB instance.
Returns: A promise resolving to the initialized instance of the Indexed class.
Counts the number of records in the object store.
Returns: A promise resolving to an object with data or error information.
Checks if a record with the given key exists in the object store.
Parameter | Type | Description |
---|---|---|
key |
* |
The key to check for existence. |
Returns: A promise resolving to an object with data or error information.
Retrieves the value of a record with the given key from the object store.
Parameter | Type | Description |
---|---|---|
key |
* |
The key of the record to retrieve. |
Returns: A promise resolving to an object with data or error information.
Puts a key-value pair into the object store.
Parameter | Type | Description |
---|---|---|
key |
* |
The key of the record. |
value |
* |
The value of the record. |
Returns: A promise resolving to an object with data or error information.
Deletes a record with the given key from the object store.
Parameter | Type | Description |
---|---|---|
key |
* |
The key of the record to delete. |
Returns: A promise resolving to an object with data or error information.
Performs a batch operation on the object store.
Parameter | Type | Description |
---|---|---|
ops |
Array<Object> |
An array of operations (put or del) to perform in the batch. |
Returns: A promise resolving to an object with data or error information.
Reads all records from the object store based on the provided options.
Parameter | Type | Description |
---|---|---|
opts |
Object |
Options for reading records. |
Returns: A promise resolving to an object with data or error information.
Reads records from the object store based on the provided options.
Parameter | Type | Description |
---|---|---|
opts |
Object , optional |
Options for reading records (default is an empty object). |
Returns: A promise resolving to an object with data or error information.