Skip to content

fielded/pouchdb-react-native

 
 

Repository files navigation

Logo

bitHound Overall Score npm Package npm Package travis-ci.org js-standard-style license

pouchdb-react-native

PouchDB, the ReactNative-only edition. A preset representing the PouchDB code that runs in ReactNative.

The pouchdb-react-native preset contains the version of PouchDB that is designed for ReactNative. In particular, it ships with the AsyncStorage adapters as its default adapters. It also contains the replication, HTTP, and map/reduce plugins.

Usage

npm install pouchdb-react-native --save

npm >= 3 / node >= 6 works best, there are some known issues with npm 2

import PouchDB from 'pouchdb-react-native'
const db = new PouchDB('mydb')

// use PouchDB
db.get('4711')
  .then(doc => console.log(doc))

For full API documentation and guides on PouchDB, see PouchDB.com.

Sample App

there is a small example app: https://github.com/stockulus/pouchdb-react-native/tree/master/example

pouchdb-adapter-asyncstorage

PouchDB adapter using AsyncStorage as its data store. Designed to run in ReactNative. Its adapter name is 'asyncstorage'.

Usage

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))

Android limit

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);

known issues

There are still Problems with Attachments, but i did not find private time to investigate more. My Current Projects do not need attachments, and I don't get paid for this package.

If you want to fix that, please go ahead, PR and help is welcome.

development

git clone https://github.com/stockulus/pouchdb-react-native.git
cd pouchdb-react-native
npm install
npm test
cd example
npm run ios

Twitter URL GitHub stars

Packages

No packages published

Languages

  • JavaScript 82.3%
  • Objective-C 8.7%
  • Shell 3.4%
  • Python 3.2%
  • Java 2.4%