oada-app-cache
v0.1.1
Published
A javascript wrapper for syncing data between an OADA server and a PouchDb cache.
Downloads
2
Readme
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);