{"id":8103,"date":"2015-11-26T13:39:58","date_gmt":"2015-11-26T13:39:58","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2015\/11\/26\/how-to-replicate-pouchdb-with-angular-js-open-source-projects-pouchdb-pouchdb\/"},"modified":"2022-08-30T15:03:01","modified_gmt":"2022-08-30T15:03:01","slug":"how-to-replicate-pouchdb-with-angular-js-open-source-projects-pouchdb-pouchdb","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2015\/11\/26\/how-to-replicate-pouchdb-with-angular-js-open-source-projects-pouchdb-pouchdb\/","title":{"rendered":"How to replicate pouchdb with angular js-open source projects pouchdb\/pouchdb"},"content":{"rendered":"<p>I&#8217;m using Couch DB to store locations for my cordova ionic app. I&#8217;m also using PouchDB for replicating the data. Everything works great but it seems like the first replication doesn&#8217;t get to finish before my application continues. That cause my data not show until the the second time i enter the page. The &#8220;complete&#8221; option doesn&#8217;t seems to work(Or i don&#8217;t know how to use it because the alert doesn&#8217;t get fired). I tried to resolve everything but no change.<\/p>\n<p>Here is my code in an angular service:<\/p>\n<pre><code>var db = new PouchDB('gardens');\nvar remoteDB = \"https:\/\/test.couchappy.com\/test\";\nvar opts = {continuous: true, xhrFields:{withCredentials:true}, complete: function() {\n  alert('test');\n}};\ndb.replicate.from(remoteDB, opts);\nvar gardens2 = [];\n\ndb.allDocs({include_docs: true}, function(err, doc) {\n  console.log(doc);\n  _.each(doc.rows, function(i){\n    console.log(i.doc.name);\n    gardens2.push({\n      name: i.doc.name,\n      lat: i.doc.lat,\n      lng: i.doc.lng,\n      message: i.doc.message\n    });\n  });\n  console.log(gardens2);\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m using Couch DB to store locations for my cordova ionic app. I&#8217;m also using PouchDB for replicating the data. Everything works great but it seems like the first replication doesn&#8217;t get to finish before my application continues. That cause my data not show until the the second time i enter the page. The &#8220;complete&#8221; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-8103","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/8103","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=8103"}],"version-history":[{"count":1,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/8103\/revisions"}],"predecessor-version":[{"id":8620,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/8103\/revisions\/8620"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=8103"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=8103"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=8103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}