1.0.1 • Published 10 years ago

crudlet-local-storage v1.0.1

Weekly downloads
3
License
ISC
Repository
github
Last release
10 years ago

Build Status Coverage Status Dependency Status

This module is a local storage database adapter for crudlet - a library that makes it easy to persist data through multiple transports.

Features

  • offline-mode - enable users to browse your application without an API (assuming there's local data)
  • faster initial load times - great for mobile devices
  • can be used with other database transports such as crudlet-http
  • cascades operations to other transports

installation

npm install crudlet-local-storage
var crudlet = require("crudlet");
var localdb = require("crudlet-local-storage");

var db = crudlet(localdb());

db localdb(options)

creates a local crudelt database

  • options - options for the local db
    • storageKey - storage key to use
    • store - store to use
var db = localdb({
  storageKey: "storage-key",
  store: {
    get: function(storageKey) {
      // return DB yere
    },
    set: function(storageKey, value) {
      // set db here
    }
  }
});

db.run(operation, options, onComplete)

runs an operation

  • operation - operation to run can be: insert, remove, update, or load
  • options - operation specific options

insert options:

  • data - data to insert. Can be an object, or an array to insert multiple
db.run("insert", { data: [{ name: "a"}, { name: "b" }]}); // insert two items
db.run("insert", { data: { name: "gg"}}); // insert one item

remove options:

  • query - mongodb search query
  • multi - TRUE if you want to remove multiple items (false by default)

update options:

  • query - mongodb search query
  • multi - TRUE if you want to update multiple items (false by default)
  • data - data to set - this is merged with existing data

load options:

  • query - mongodb search query
  • multi - TRUE if you want to load multiple items (one by default)
1.0.1

10 years ago

1.0.0

10 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.1

10 years ago