All Projects → eldomagan → vuex-orm-localforage

eldomagan / vuex-orm-localforage

Licence: MIT License
Vuex ORM persistence plugin to sync the store against IndexedDB using localforage

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to vuex-orm-localforage

Localforage
💾 Offline storage, improved. Wraps IndexedDB, WebSQL, or localStorage using a simple but powerful API.
Stars: ✭ 19,840 (+38801.96%)
Mutual labels:  indexeddb, localforage
client-persist
Offline storage for your web client. Supports IndexedDB, WebSQL, localStorage and sessionStorage with an easy to crawl with API.
Stars: ✭ 14 (-72.55%)
Mutual labels:  indexeddb, localforage
Vuex Orm
The Vuex plugin to enable Object-Relational Mapping access to the Vuex Store.
Stars: ✭ 2,308 (+4425.49%)
Mutual labels:  vuex-plugin, vuex-orm
localForage-cn
localForage中文仓库,localForage改进了离线存储,提供简洁健壮的API,包括 IndexedDB, WebSQL, 和 localStorage。
Stars: ✭ 201 (+294.12%)
Mutual labels:  indexeddb, localforage
shu-scheduling-helper
A web-based timetabler helping SHUers filter and preselect courses easily. SHU排课助手. 上海大学排课助手.
Stars: ✭ 43 (-15.69%)
Mutual labels:  localforage
dexie-encrypted
Transparent encryption for IndexedDB using Dexie
Stars: ✭ 66 (+29.41%)
Mutual labels:  indexeddb
secure-webstore
A secure IndexedDB store with built-in encryption
Stars: ✭ 35 (-31.37%)
Mutual labels:  indexeddb
vuex-analysis
学习源码整体架构系列8篇之vuex源码,前端面试高频源码,微信搜索「若川视野」关注我,长期交流学习~
Stars: ✭ 36 (-29.41%)
Mutual labels:  vuex-plugin
persistence
💾 Persistence provides a pretty easy API to handle Storage's implementations.
Stars: ✭ 18 (-64.71%)
Mutual labels:  indexeddb
sync-client
SyncProxy javascript client with support for all major embedded databases (IndexedDB, SQLite, WebSQL, LokiJS...)
Stars: ✭ 30 (-41.18%)
Mutual labels:  indexeddb
idbstudio
idbstudio is a management tools for indexeddb library jsstore. It helps users to execute , debug and learn jsstore query.
Stars: ✭ 30 (-41.18%)
Mutual labels:  indexeddb
localforage-asyncstorage-driver
Driver which enables you to use localforage for React-Native's AsyncStorage API
Stars: ✭ 18 (-64.71%)
Mutual labels:  localforage
pouchy
A simple, opinionated interface for PouchDB 👝
Stars: ✭ 59 (+15.69%)
Mutual labels:  indexeddb
electron-react-ts-rxdb-realm-sqlite
Demo of Native Databases with Electron and ReactJS. Realm, SQLite and RxDB ( with LevelDB/IndexedDB/InMemory adapters)
Stars: ✭ 27 (-47.06%)
Mutual labels:  indexeddb
vuex-typed-modules
🧰 A VueX wrapper to fully type your modules without boilerplate!
Stars: ✭ 35 (-31.37%)
Mutual labels:  vuex-plugin
deadlines
A simple, offline deadline tracker made with Vue.js and localForage.
Stars: ✭ 22 (-56.86%)
Mutual labels:  localforage
sqlweb
SqlWeb is an extension of JsStore which allows to use sql query for performing database operation in IndexedDB.
Stars: ✭ 38 (-25.49%)
Mutual labels:  indexeddb
awesome-vuex-orm
A curated list of awesome things related to Vuex ORM.
Stars: ✭ 52 (+1.96%)
Mutual labels:  vuex-orm
YASCC
Yet Another SoundCloud Client
Stars: ✭ 30 (-41.18%)
Mutual labels:  indexeddb
WaWebSessionHandler
(DISCONTINUED) Save WhatsApp Web Sessions as files and open them everywhere!
Stars: ✭ 27 (-47.06%)
Mutual labels:  indexeddb

JavaScript Style Guide License

Vuex ORM Plugin: LocalForage

VuexORMLocalforage is a plugin for the amazing VuexORM that let you sync your Vuex Store with an IndexedDB database using LocalForage.

Installation

Add the package to your dependencies

yarn add vuex-orm-localforage

Or

npm install --save vuex-orm-localforage

Then you can setup the plugin

import VuexORM from '@vuex-orm/core'
import VuexORMLocalForage from 'vuex-orm-localforage'

const database = new VuexORM.Database()

VuexORM.use(VuexORMLocalForage, {
  database
})

// ...

export default () => new Vuex.Store({
  namespaced: true,
  plugins: [VuexORM.install(database)]
})

See https://vuex-orm.github.io/vuex-orm/guide/prologue/getting-started.html#create-modules on how to setup the database

Actions

This plugin add some vuex actions to load and persist data in an IndexedDB

Action Description
$fetch Load data from the IndexedDB store associated to a model and persist them in the Vuex Store
$get Load data by id from the IndexedDB store associated and persist it to Vuex Store
$create Like VuexORM insertOrUpdate, but also persist data to IndexedDB
$update Update records using VuexORM update or insertOrUpdate then persist changes to IndexedDB
$replace Like VuexORM create, but also replace all data from IndexedDB
$delete Like VuexORM delete, but also remove data from IndexedDB
$deleteAll Like VuexORM deleteAll, but also delete all data from IndexedDB

Example Usage

<template>
  <div>
    <input type="text" v-model="todo">
    <input type="button" @click="addTodo">

    <ul>
      <li v-for="todo in todos" :key="todo.id">{{ todo.title }}</li>
    </ul>
  </div>
</template>

<script>
  import Todo from './store/models/Todo'

  export default {
    data () {
      return {
        todo: ''
      }
    },

    computed: {
      todos () {
        return Todo.query().all()
      }
    },

    async mounted () {
      // Load todos from IndexedDB
      await Todo.$fetch()
    },

    methods: {
      addTodo () {
        if (this.todo) {
          // Insert the todo in VuexORM Store and also persist it to IndexedDB
          Todo.$create({
            title: this.todo
          })
        }
      }
    }
  }
</script>

Configuration Options

These are options you can pass when calling VuexORM.use()

{
  // The VuexORM Database instance
  database,

  /**
   * LocalForage config options
   *
   * @see https://github.com/localForage/localForage#configuration
   */
  localforage: {
    name: 'vuex', // Name is required
    ...
  },

  /**
   * You can override names of actions introduced by this plugin
   */
  actions: {
    $get: '$get',
    $fetch: '$fetch',
    $create: '$create',
    $update: '$update',
    $replace: '$replace',
    $delete: '$delete',
    $deleteAll: '$deleteAll'
  }
}

You can also override localforage config per model

class Post extends Model {
  static localforage = {
    driver: localforage.WEBSQL,
    storeName: 'my_posts'
  }
}

Using with other VuexORM Plugin

There may be a conflict when using this plugin along with other VuexORM plugins as they are following the same API (aka they introduced the same actions: $fetch, $create...)

Just override actions names like that

VuexORM.use(VuexORMLocalForage, {
  database,
  actions: {
    $get: '$getFromLocal',
    $fetch: '$fetchFromLocal',
    $create: '$createLocally',
    $update: '$updateLocally',
    $replace: '$replaceLocally',
    $delete: '$deleteFromLocal',
    $deleteAll: '$deleteAllFromLocal'
  }
})

Then

Post.$fetchFromLocal() // instead of Post.$fetch()
...
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].