4

For some reason documents created on my app are not showing up on my remote couchdb database.

I am using the following

import PouchDB from 'pouchdb-react-native'

let company_id = await AsyncStorage.getItem('company_id');
let device_db = new PouchDB(company_id, {auto_compaction: true});
let remote_db = new PouchDB('https://'+API_KEY+'@'+SERVER+'/'+company_id, {ajax: {timeout: 180000}});

device_db.replicate.to(remote_db).then((resp) => {

    console.log(JSON.stringify(resp));
    console.log("Device to Remote Server - Success");
    return resp;

}, (error) => { 

  console.log("Device to Remote Server - Error");
  return false; 

});

I get a successful response the response:

{
  "ok":true,
  "start_time":"2018-05-17T15:19:05.179Z",
  "docs_read":0,
  "docs_written":0,
  "doc_write_failures":0,
  "errors":[

  ],
  "last_seq":355,
  "status":"complete",
  "end_time":"2018-05-17T15:19:05.555Z"
}

When I go to my remote database, document_id's that am able to search and grab on the application do not show up.

  • Is there something I am not taking into account?
  • Is there anything I can do to check why this might be happening?
  • This worked when I used the same scripting method in Ionic and when I switched to React-Native I noticed this is the case.

NOTE: When I do .from() and get data from remote to the device, I get the data. For some reason it just isn't pushing data out

bryan
  • 8,879
  • 18
  • 83
  • 166

1 Answers1

0

"Is there anything I can do to check why this might be happening?"

I would try switching on debugging as outlined here.

PouchDB.debug.enable('*');

This should allow you to view debug messages in your browser's JavaScript console.

enter image description here

Glynn Bird
  • 5,507
  • 2
  • 12
  • 21
  • I appreciate this insight but I'm not seeing anything out of the ordinary however nowhere in the logs am I seeing document ID's I know exist. From my above code, if I have a document ID on my device that I am able to `.get()`, is there a way to see why it isn't being pushed? – bryan May 18 '18 at 12:40
  • Perhaps try from a clean client-side database? From a standing start you should see the client site calling the remote side's `POST _bulk_docs` endpoint until all the docs are replicated. You should also see `_local/x` checkpoint files being written. It maybe that PouchDB "thinks" it is up-to-date because the checkpoint files are telling it that it has no more changes to replicate? – Glynn Bird May 18 '18 at 12:45
  • I don't see a `_local/x` checkpoint at all. Hmm, okay I will try this but I have documents I need to keep at the moment and is a bit worrisome if the problem can only be fixed by deleting data I need :\ If I replicate from cloud to device, create documents on the device, then replicate device to cloud. Would that be an issue? – bryan May 18 '18 at 12:47