Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to give visitors to a mobile website offline access to CouchDB data?

For users who do not install CouchDB on Android, what is the best practices way of giving them offline access to my CouchDB data (using Node.js)?

Here's my guess: When the user is online, read CouchDB data and output JS object literal listing the data. Store JS object literal in local storage with browsercouch. Offline visitor will then be able to get data from local storage.

like image 594
edt Avatar asked May 20 '11 04:05

edt


1 Answers

That is definitely the best solution for now (May 2011). Hopefully in the near future, this question will be edited to say "just use the mobile Couchbase SDK."

But for now, use localStorage to keep everything you need. A good idea is to remember the seq_id from the database the last time you contacted it. When you go back online, you can query the couch's /db/_changes?since=$old_seq_id and CouchDB will tell you all documents that were added or modified since then.

Finally, in addition to browsercouch, Mikeal Rogers and others are working on IndexedDBCouch, IDBCouch, which is very new but aims to re-implement CouchDB in the web browser (possibly in webkit views one day; I'm not sure). https://github.com/mikeal/IDBCouch

like image 118
JasonSmith Avatar answered Oct 03 '22 01:10

JasonSmith