与PouchDB类似的东西会很棒。
当前键值存储(AsyncStorage
)绝对不足以存储和查询数据。
答案 0 :(得分:1)
我遇到了一些问题,让PouchDB处理react-native,但不想安装SQLLite。所以我构建了一个异步存储适配器。
它补充了React的缺失包+在" asyncstorage-down"上添加了一个异步存储适配器。适当的帮助。
答案 1 :(得分:1)
我尝试过使用Stockulus'异步存储适配器(https://github.com/stockulus/pouchdb-react-native)但在复制到远程CouchDB服务器时遇到问题。
现在我正在使用React原生SQLite存储(https://github.com/andpor/react-native-sqlite-storage)和PouchDB自定义构建模式(https://pouchdb.com/2016/06/06/introducing-pouchdb-custom-builds.html),如下所示:
'use strict';
import PouchDB from 'pouchdb-core'
// POLYFILLS - adapted from https://github.com/pouchdb/pouchdb/issues/3787#issuecomment-234618747
global.Buffer = global.Buffer || require('buffer').Buffer;
global.atob = global.atob || require('atob');
global.btoa = global.btoa || require('btoa');
require('blob-polyfill');
import SQLite from 'react-native-sqlite-storage';
global.openDatabase = SQLite.openDatabase; // Expose for websql adapter
GLOBAL.openDatabase = SQLite.openDatabase;
PouchDB
.plugin(require('pouchdb-adapter-websql'))
.plugin(require('pouchdb-adapter-http'))
.plugin(require('pouchdb-replication'))
export default PouchDB
我知道全球是丑陋的。我们刚开始使用它,复制工作得更好。我们还必须填充一堆节点内容。这由pouchdb-core使用,但未在pouchdb-core中指定为依赖项。会喜欢反馈。
目前正在使用这些套餐:
"events": "^1.1.1",
"pouchdb-adapter-http": "6.0.6",
"pouchdb-adapter-websql": "6.0.6",
"pouchdb-core": "6.0.6",
"pouchdb-replication": "6.0.6",
"atob": "^2.0.3",
"blob-polyfill": "^1.0.20150320",
"btoa": "^1.1.2",
"buffer": "^5.0.0",
由于
答案 2 :(得分:0)
You can easily implement PouchDB on top on SQLLite - it has several configuration choices. You may need a SQLite Plugin to make it work. I have done this for Cordova in fact and it worked quite well. I believe PouchDB (which is pure JavaScript and therefore can be used out-of-the-box for ReactNative) has an adapter that works with the full featured SQLite3 Plugin.
React Native version of this plugin is available here:
https://github.com/andpor/react-native-sqlite-storage
The original Cordova plugin link can be found on the project github as well.