All Projects → mkuklis → Depot.js

mkuklis / Depot.js

📦 depot.js is a storage library with a simple API

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Depot.js

Store.js
Cross-browser storage for all use cases, used across the web.
Stars: ✭ 13,656 (+5428.74%)
Mutual labels:  serialization, storage, localstorage
Bojack
🐴 The unreliable key-value store
Stars: ✭ 101 (-59.11%)
Mutual labels:  storage, store
Vlf
A Vue plugin from localForage.vue-localForage or vlf
Stars: ✭ 99 (-59.92%)
Mutual labels:  storage, localstorage
Store
A better way to use localStorage and sessionStorage
Stars: ✭ 1,646 (+566.4%)
Mutual labels:  storage, localstorage
Prefser
Wrapper for Android SharedPreferences with object serialization and RxJava Observables
Stars: ✭ 228 (-7.69%)
Mutual labels:  serialization, storage
Node Scalable Blob Store
A file system blob store that is designed to prevent conflicts when used with a distributed file system or storage area network
Stars: ✭ 31 (-87.45%)
Mutual labels:  storage, store
Cash
HTTP response caching for Koa. Supports Redis, in-memory store, and more!
Stars: ✭ 122 (-50.61%)
Mutual labels:  storage, store
Binaryprefs
Rapidly fast and lightweight re-implementation of SharedPreferences which stores each preference in files separately, performs disk operations via NIO with memory mapped byte buffers and works IPC (between processes). Written from scratch.
Stars: ✭ 484 (+95.95%)
Mutual labels:  serialization, storage
React Storage Hooks
React hooks for persistent state
Stars: ✭ 146 (-40.89%)
Mutual labels:  storage, localstorage
Vue Warehouse
A Cross-browser storage for Vue.js and Nuxt.js, with plugins support and easy extensibility based on Store.js.
Stars: ✭ 161 (-34.82%)
Mutual labels:  storage, localstorage
Remotestorage.js
⬡ JavaScript client library for integrating remoteStorage in apps
Stars: ✭ 2,155 (+772.47%)
Mutual labels:  storage, localstorage
Proxy Storage
Provides an adapter for storage mechanisms (cookies, localStorage, sessionStorage, memoryStorage) and implements the Web Storage interface
Stars: ✭ 10 (-95.95%)
Mutual labels:  storage, localstorage
Weibo Picture Store
🖼 新浪微博图床 Chrome/Firefox 扩展,支持同步到微相册
Stars: ✭ 624 (+152.63%)
Mutual labels:  storage, store
Recoil Persist
Package for recoil state manager to persist and rehydrate store
Stars: ✭ 66 (-73.28%)
Mutual labels:  storage, localstorage
Vuex Persistedstate
💾 Persist and rehydrate your Vuex state between page reloads.
Stars: ✭ 5,561 (+2151.42%)
Mutual labels:  storage, localstorage
Flatdata
Write-once, read-many, minimal overhead binary structured file format.
Stars: ✭ 121 (-51.01%)
Mutual labels:  serialization, storage
Localforage
💾 Offline storage, improved. Wraps IndexedDB, WebSQL, or localStorage using a simple but powerful API.
Stars: ✭ 19,840 (+7932.39%)
Mutual labels:  storage, localstorage
Vue Ls
💥 Vue plugin for work with local storage, session storage and memory storage from Vue context
Stars: ✭ 468 (+89.47%)
Mutual labels:  storage, localstorage
Vuex Localstorage
Persist Vuex state with expires by localStorage or some else storage.
Stars: ✭ 129 (-47.77%)
Mutual labels:  storage, localstorage
Flutter localstorage
📦flutter localstorage for ios/android/desktop/web
Stars: ✭ 206 (-16.6%)
Mutual labels:  storage, localstorage

📦 depot.js

build status

Description

depot.js is a namespaced localStorage wrapper with a simple API. There are other tools out there but none of them had what I was looking for.

Setup

You can install depot.js via npm:

  npm install depotjs --save

or load it directly via <script src="depot.browser.js"></script>. The dist folder contains the most recent minified browser version depot.browser.js.

Dependencies

depot.js does not depend on any other libraries however if you plan to support older browsers you will need to include ES5-shim.

If you plan to run it on browsers that don't support localStorage you may try to include storage polyfill.

API

  • save(record)

  • saveAll(array)

  • updateAll(hash)

  • update(hash)

  • find(hash | function)

  • all()

  • destroy(id | record)

  • destroyAll(none | hash | function)

  • get(id)

  • size()

Usage

Import depot

import depot from 'depotjs';

Define new store

const todos = depot('todos');

Add new records

_id property will be generated as GUID and attached to each new record:

todos.save({ title: "todo1" });
todos.save({ title: "todo2", completed: true });
todos.save({ title: "todo3", completed: true });

Add multiple records at once

todos.saveAll([ { title: "todo1" }, { title: "todo2" }, { title: "todo3" } ]);

Update all records

todos.updateAll({ completed: false });

Return all records

todos.all(); // [{ _id: 1, title "todo1" }, { _id: 2, title: todo2 }]

Find records

  • find based on given criteria
todos.find({ completed: true }); // [{ _id: 2, title: "todo2" }, { _id: 3, title: "todo3" }]
  • find based on given function
todos.find(record => record.completed && record.title == "todo3"); // [{ _id: 3, title: "todo3" }]

Return single record by id

todos.get(1); // { _id: 1, title: "todo1" }

Destroy single record

  • by record id
todos.destroy(1);
  • by record object
todos.destroy(todo);

Destroy all records

  • destroy all
todos.destroyAll();
  • destroy by given criteria
todos.destroyAll({ completed: true });
  • destroy by given function
todos.destroyAll(record => record.completed && record.title === "todo3");

Options

You can pass a second parameter to depot with additional options.

const todos = depot("todos", options);

Available options:

  • idAttribute - used to override record id property (default: _id)
const todos = depot("todos", { idAttribute: 'id' });
  • storageAdaptor - used to override storage type (default: localStorage)
const todos = depot('todos', { storageAdaptor: sessionStorage });

License:

The MIT License
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].