0.1.1 • Published 7 years ago

oada-app-cache v0.1.1

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

Install

npm install oada-app-cache

API

var cache = require('oada-app-cache');

db

db is a function that returns PouchDB instance. It can be used by the cache if you want to share with it.

var db = require('oada-app-cache').db

.setup(domain, token, oadaTree, pouchdbInstanceName)

var oadaTree = {
	rocks: {
    _type: 'application/vnd.oada.rocks.1+json',
    'list-index': {
      '*': {
      },
    },
  },
};
cache.setup(domain, token, oadaTree, 'TheRockApp');

.get(url, token)

var url = 'https://' + domain + '/bookmarks/rocks/list-index/';
cache.get(url, token);

.put(domain, token, bookmarkUrl, data)

var bookmarkUrl = 'https://' + domain + '/bookmarks/rocks/list-index/' + data.id + '/';
var data = {
  id: id,
  location: {
    latitude: lat,
    longitude: lng,
  },
  picked: false,
  comments: '',
  sync_status: 'new',
};
cache.put(domain, token, bookmarkUrl, data);

.delete(resourceUrl, token)

var resourceUrl = 'https://' + domain + '/resources/' + obj.id + '/';
cache.delete(url, token);