0

I'm using Cloudant and I'm struggling to pull/replicate 600 documents from server to my iPhone. First, it's pretty slow because it has to go one-document-at-a-time, and Second Cloudant was giving me "timeouts" after the 100th-or-so REST request. (I have a ticket with Cloudant for this one, as it's unacceptable!)

I was wondering if anyone has found a way / hack to "bulk" replicate when pulling. I was thinking, perhaps it's possible to "zip up" all of the changes, send them in one file, and fast-forward the iPhone database to the last-change seq.

Any helps is great -- thanks!

alessioalex
  • 62,577
  • 16
  • 155
  • 122
ewindsor
  • 885
  • 10
  • 24
  • Sorry, I'm confused, are you trying to replicate the entire database or just some docs? Because if it's just some, you could use "doc_ids":["1","2"...], and if it's the entire database then you could just replicate the entire database, no? – fet Nov 09 '12 at 18:14

2 Answers2

0

Can you not hit _all_docs?include_docs=true to get everything in one shot? http://wiki.apache.org/couchdb/HTTP_Document_API#all_docs

I don't know couchcoccoa but it looks like the API supports this: http://couchbaselabs.github.com/CouchCocoa/docs/interfaceCouchDatabase.html#a49d0904f438587b988860891e8049885

  • I could do _all_docs, but I'd still need to figure out the last_seq and manually update it... right? I'm thinking this wouldn't be the best solution for multiple pull-replications that would need to happen down the line (like if I retrieve all the docs the first time, and the second time there's only 2 new but I'd still get them all...) Thanks for your input, I'm still learning Couch and how it works :) – ewindsor May 25 '12 at 07:00
0

Actually, why not make a view. Make a view that gives you your list and make sure your id is there. With your id, you can then go to the document and get all the rest of the required information that you need in order to update it if you need to.

There really is no reason you would ever need to hit every document individually. They have views and search2.0 for that. Keep in mind you are using a cloud based technology. This stuff is not sitting in your basement, you can't just hit it a million times per device in a few seconds and expect anyone to not notice and/or get upset (an exaggeration, yes I know).

What I do not understand is that you are trying to replicate it to an iPhone? Are you running apache and couchdb in your app? Why not just read the JSON data and throw it into a database. or just throw it into a file if it updates that much and keep overwriting it. There is so many options that are a whole lot less messy.

AlienDev
  • 333
  • 2
  • 16