PouchDB adapter using AsyncStorage as its data store. Designed to run in ReactNative. Its adapter name is 'asyncstorage'
.
npm install pouchdb-adapter-asyncstorage --save
import PouchDB from 'pouchdb-core'
PouchDB.plugin(require('pouchdb-adapter-asyncstorage').default)
const db = new PouchDB('mydb', {adapter: 'asyncstorage'})
// use PouchDB
db.get('4711')
.then(doc => console.log(doc))
Be careful when using this with other AsyncStorage data or multiple databases as it loads all keys in your store into memory. You can use react-native-async-storage-rocks if this is an issue for you (see below).
On Android asyncstorage has a limitation of 6 MB per default, you might want to increase it
// MainApplication.getPackages()
long size = 50L * 1024L * 1024L; // 50 MB
com.facebook.react.modules.storage.ReactDatabaseSupplier.getInstance(getApplicationContext()).setMaximumSize(size);
If you are using react-native-async-storage-rocks then pouchdb-adapter-asyncstorage will detect and use the native getKeysWithPrefix
method for memory-efficient key lookups.
For full API documentation and guides on PouchDB, see PouchDB.com. For details on PouchDB sub-packages, see the Custom Builds documentation.