1

When replicating from couchDB(with geocouch), is there a way to sync documents within a bbox (bounds) ?

I'm displaying markers on a map, and I'd like to only replicate documents within the bounds of that map.

Thank you.

abernier
  • 27,030
  • 20
  • 83
  • 114

1 Answers1

1

Yes because the underlying documents are the same. When you query for a bounding box the result set should contain a list of document ids. The replicator api in couchdb can accept a list of document ids that have to be replicated. So all you have got to do is query for the bbox to get a list of _ids and pass that list to the couchdb replicator to replicate them.

Akshat Jiwan Sharma
  • 15,430
  • 13
  • 50
  • 60
  • If I understand correctly, what I have to do is: 1. Make a GET `?bbox=` request to geocouch and extract `docIds` from the response 2. `PouchDB.replicate('mydb', 'http://localhost:5984/mydb', {doc_ids: docIds})` Also, when map's bounds change: I cancel replication and repeat the previous process -- do you agree and do you see anything else? Thank you – abernier Oct 16 '14 at 10:50
  • Yes. I answered this question assuming that you are replicating with couchdb api... I am not familiar with pouchdb's replication api but a quick google search shows me that should work. – Akshat Jiwan Sharma Oct 16 '14 at 12:07
  • What about new created documents ? If I use your technique (ie: listening on specific ids) I won't benefit from live pouchdb replicate feature... do you see another option ? – abernier Nov 01 '14 at 19:46