@storage-js/vue-localforagedeprecated

A plugin wrapped from localForage for Vue.js.

Usage no npm install needed!

<script type="module">
  import storageJsVueLocalforage from 'https://cdn.skypack.dev/@storage-js/vue-localforage';
</script>

README

@storage-js/vue-localforage

NPM Version Downloads MIT License

Build Status Build status Coverage Status

Code Climate Test Coverage Issue Count

Dependencies Status devDependencies Status peerDependencies Status

Semantic Release Average time to resolve an issue Percentage of issues still open Gitter

A plugin wrapped from localForage for Vue.js.

Installation

Install using npm

# install it via npm
npm install @storage-js/vue-localforage --save

Install using yarn

# install it via yarn
yarn add @storage-js/vue-localforage

Direct usage with html

<!-- insert the vue core before it -->
<script src="https://unpkg.com/@storage-js/vue-localforage"></script>

Usage

// register the plugin on vue
import VueLocalforage from '@storage-js/vue-localforage';

Vue.use(VueLocalforage);

// you can also pass options, check options reference below
Vue.use(VueLocalforage, Options);

Get item

let item = await this.$localForage.getItem(key)

Set item

await this.$localForage.setItem(key, value)

Remove item

await this.$localForage.removeItem(key)

Clear

await this.$localForage.clear()

Gets the length

let length = await this.$localForage.length()

Get the name of a key based on its ID

let k = await this.$localForage.key(keyIndex)

Get the list of all keys

let keys = await this.$localForage.keys()

More informations on LocalForage documentation

Advanced Usage

You can register multiple instances, see below:

Vue.use(VueLocalforage, {
    instances: [
        {
            storeName: 'instance1'
        },

        {
            storeName: 'instance2'
        }
    ]
});

// for instance1
await this.$localForage.instance1.setItem(key, value)

// for instance2
await this.$localForage.instance2.setItem(key, value)

Options

instances (optional)

  • Default: []

You can create multiple instances.

driver (optional)

  • Default: [localforage.INDEXEDDB, localforage.WEBSQL, localforage.LOCALSTORAGE]

The preferred driver(s) to use.

name (optional)

  • Default: localforage

The name of the database.

size (optional)

  • Default: 4980736

The size of the database in bytes.

storeName (optional)

  • Default: keyvaluepairs

The name of the datastore.

version (optional)

  • Default: 1.0

The schema version of your database.

description (optional)

  • Default: ``

A description of the database.

More informations on LocalForage documentation

License

MIT License

Contributors