idbkeyvalue

1.0.3 • Public • Published

idbkeyvalue

idbkeyvalue is a lightweight npm package that simplifies key-value storage using the IndexedDB API. It provides an easy-to-use interface for common operations like setting, getting, updating, and deleting key-value pairs, making it a convenient solution for client-side storage in web applications.

Installation

To install the package, use npm:

npm install idbkeyvalue

Usage

Using the CDN

You can include the idbkeyvalue library directly in your HTML file using the following CDN URL:

<!-- Include the idbkeyvalue library from jsDelivr CDN -->
<script src="https://cdn.jsdelivr.net/npm/idbkeyvalue@1.0.2/keyvalue.js"></script>

Opening or Creating a Database

import { openDB } from 'idbkeyvalue';

// Open or create a default database
openDB();

Setting a Key-Value Pair

import { insert } from 'idbkeyvalue';

// Set a key-value pair
insert('exampleKey', 'exampleValue');

Getting a Value by Key

import { get } from 'idbkeyvalue';

// Get the value by key
(async () => {
  const retrievedValue = await get('exampleKey');
  console.log(retrievedValue);
})();

Updating a Value by Key

import { update } from 'idbkeyvalue';

// Update the value by key
update('exampleKey', 'newValue');

Deleting a Key-Value Pair

import { deleteKeyValue } from 'idbkeyvalue';

// Delete the key-value pair
deleteKeyValue('exampleKey');

Set or Update a Key-Value Pair

import { set } from 'idbkeyvalue';

// Set or update a key-value pair
set('exampleKey', 'exampleValue');

Contributing

We welcome contributions! Feel free to open an issue or submit a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.


Feel free to customize the README file based on your specific needs and additional information you'd like to include.

Package Sidebar

Install

npm i idbkeyvalue

Weekly Downloads

19

Version

1.0.3

License

MIT

Unpacked Size

12.2 kB

Total Files

4

Last publish

Collaborators

  • technicalheist