javascript - 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 不会出现。
- 有什么我没有考虑到的吗?
- 我可以做些什么来检查为什么会发生这种情况?
- 当我在 Ionic 中使用相同的脚本方法时,这很有效,当我切换到 React-Native 时,我注意到情况就是这样。
注意:当我.from()
从远程获取数据到设备时,我得到了数据。出于某种原因,它只是没有推出数据
解决方案
“我能做些什么来检查为什么会发生这种情况吗?”
我会尝试按照此处所述打开调试。
PouchDB.debug.enable('*');
这应该允许您在浏览器的 JavaScript 控制台中查看调试消息。
推荐阅读
- node.js - 将localstorage中的数据同步到mongodb
- c - 为什么随机测试用例会出现“运行时错误:分段错误”?
- delphi - 我可以在不使用位图的情况下更改肤色吗?
- node.js - Cloud Run Build 期间未定义环境变量
- python - 为什么计算 XGBoost 时我的学习曲线没有意义?
- ios - App Store Connect 中未出现或处理新上传的构建版本
- azure - 如何在 Databricks 中的 Iceberg 表上执行 Spark SQL 合并语句?
- asp.net-core-5.0 - 尝试在登录后强制用户更改密码
- java - ScriptEngine 的 JDK16 问题(使用 Graal)
- java - 使用嵌入式内存 postgresql DB 的 Java Spring 引导单元测试