@kalligator/v-localforage

0.0.1 • Public • Published

v-localforage

A plugin wrapped from localForage for Vue.js.

Installation

Install using npm

# install it via npm
npm install @kalligator/v-localforage --save

Usage

// register the plugin on vue
import VueLocalforage from '@kalligator/v-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

Package Sidebar

Install

npm i @kalligator/v-localforage

Weekly Downloads

1

Version

0.0.1

License

MIT

Unpacked Size

147 kB

Total Files

7

Last publish

Collaborators

  • kalligator