I tried using the Stockulus asynchronous storage adapter ( https://github.com/stockulus/pouchdb-react-native ), but there were problems replicating to the remote CouchDB server.
Now I am using React native SQLite Storage ( https://github.com/andpor/react-native-sqlite-storage ) and the PouchDB custom assembly template ( https://pouchdb.com/2016/06/06/introducing-pouchdb- custom-builds.html ) as follows:
'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
I know that global ugliness. We just started using it, and replication works better. We also had to polyfill a bunch of node things. This is used by pouchdb-core, but is not indicated as a dependency in pouchdb-core. Will feedback be interesting.
Currently, the following packages are used:
"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",
thanks
theycallmethesloth
source share