首页 > 解决方案 > PouchDB 和 React-Native 不复制 .to() 但 .from() 正在工作

问题描述

由于某种原因,在我的应用程序上创建的文档没有显示在我的远程couchdb数据库中。

我正在使用以下

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; 

});

我得到一个成功的响应响应:

{
  "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"
}

当我转到我的远程数据库时,能够在应用程序上搜索和抓取的 document_id 不会出现。

注意:当我.from()从远程获取数据到设备时,我得到了数据。出于某种原因,它只是没有推出数据

标签: javascriptreact-nativecouchdbpouchdbpouchdb-adapter-localstorage

解决方案


“我能做些什么来检查为什么会发生这种情况吗?”

我会尝试按照此处所述打开调试。

PouchDB.debug.enable('*');

这应该允许您在浏览器的 JavaScript 控制台中查看调试消息。

在此处输入图像描述


推荐阅读