couchdbpouchdbcouchapp

How to integrate Pouch DB, with couchDB application which is built with jquery couch API?


I developed an application with couch DB. I used jquery couch API. Now i want to add Pouch DB also in my application. So What should be the workflow for this implementation.

For Example

Currently to insert data in couch DB, I am using this,

var mydata = {
  _id: 'dave@gmail.com',
  name: 'David',
  age: 68
};
$.couch.db('dbname').saveDoc(mydata,{
  success:function(data){
    console.log(data);
  }
});

And on Pouch DB Tutorial, they given example to insert like following

var db = new PouchDB('dbname');

db.put({
  _id: 'dave@gmail.com',
  name: 'David',
  age: 68
});

So Now As I want to add Pouch Db in my application, Do I need to change whole jquery couch API to Pouch Db API?

Or I can still achieve that with jquery couch API.?

Also My already developed CouchDB application has 3GB of database. So when I try to apply two way sync, it is just not happening.How can I handle this?


Solution

  • You can either write a proxy that will take the $.couch calls and forward them to PouchDB, or replace the $.couch ones with PouchDB calls, I would personally do the latter, the 2 apis are fairly closely matched so it should be mostly a simple find / replace

    As for the sync issue, 3G is a fair amount of data to load into the browser but it should work (with prompts) or at the least fail in a way that tells you why, if you are seeing something not working please feel free to file an issue in the pouchdb repo