Skip to content

Commit 908c6b2

Browse files
committed
docs(readme): update
1 parent bd0a0cd commit 908c6b2

File tree

1 file changed

+36
-118
lines changed

1 file changed

+36
-118
lines changed

README.md

Lines changed: 36 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
pouchdb-adapter-react-native-sqlite
2-
======
1+
# pouchdb-adapter-react-native-sqlite
32

43
PouchDB adapter using ReactNative SQLite as its backing store.
54

@@ -9,138 +8,57 @@ SQLite storage performs much faster than AsyncStorage, especially with secondary
98
Here is benchmark results:
109

1110
| 1) `allDocs` speed | min | max | mean |
12-
|---------------|------|------|------|
13-
| AsyncStorage | 72ms | 94ms | 77ms |
14-
| SQLite | 27ms | 39ms | 28ms |
11+
| ------------------ | ---- | ---- | ---- |
12+
| AsyncStorage | 72ms | 94ms | 77ms |
13+
| SQLite | 27ms | 39ms | 28ms |
1514

16-
| 2) `query` speed | min | max | mean |
17-
|---------------|---------|---------|---------|
18-
| AsyncStorage | 1,075ms | 1,117ms | 1,092ms |
19-
| SQLite | 33ms | 39ms | 35ms |
15+
| 2) `query` speed | min | max | mean |
16+
| ---------------- | ------- | ------- | ------- |
17+
| AsyncStorage | 1,075ms | 1,117ms | 1,092ms |
18+
| SQLite | 33ms | 39ms | 35ms |
2019

21-
* Device: iPhone 6s
22-
* Documents: 434
23-
* Update seq: 453
24-
* Iterations: 100
25-
* Used options: `{ include_docs: true }`
20+
- Device: iPhone 6s
21+
- Documents: 434
22+
- Update seq: 453
23+
- Iterations: 100
24+
- Used options: `{ include_docs: true }`
2625

2726
### On Simulator
2827

29-
* Device: iPad Pro 9.7" (Simulator) - iOS 10.3.2
30-
* Documents: 5000
28+
- Device: iPad Pro 9.7" (Simulator) - iOS 10.3.2
29+
- Documents: 5000
3130

32-
| 3) `bulkDocs` speed | total | mean |
33-
|---------------|----------|--------|
34-
| AsyncStorage | 25.821ms | 5.16ms |
35-
| SQLite | 22.213ms | 4.44ms |
31+
| 3) `bulkDocs` speed | total | mean |
32+
| ------------------- | -------- | ------ |
33+
| AsyncStorage | 25.821ms | 5.16ms |
34+
| SQLite | 22.213ms | 4.44ms |
3635

37-
| 4) `allDocs` speed | total | mean |
38-
|---------------|-----------|---------|
39-
| AsyncStorage | 189,379ms | 37.87ms |
40-
| SQLite | 30,527ms | 6.10ms |
36+
| 4) `allDocs` speed | total | mean |
37+
| ------------------ | --------- | ------- |
38+
| AsyncStorage | 189,379ms | 37.87ms |
39+
| SQLite | 30,527ms | 6.10ms |
4140

42-
* `allDocs` options: `{ include_docs: true, attachments: true }`
43-
* Using this test [script](https://gist.github.com/hnq90/972f6597a0927f45d9075b8627892783)
41+
- `allDocs` options: `{ include_docs: true, attachments: true }`
42+
- Using this test [script](https://gist.github.com/hnq90/972f6597a0927f45d9075b8627892783)
4443

4544
## How to use it
4645

47-
Read [this blogpost](https://dev.to/craftzdog/hacking-pouchdb-to-use-on-react-native-1gjh) for the complete description.
48-
Here is [a working demo app](https://github.com/craftzdog/pouchdb-react-native-demo).
49-
50-
### Install deps
51-
52-
Install PouchDB core packages:
53-
54-
```bash
55-
npm i pouchdb-adapter-http pouchdb-mapreduce
56-
```
57-
58-
And install hacked packages for React Native:
59-
60-
```bash
61-
npm i @craftzdog/pouchdb-core-react-native @craftzdog/pouchdb-replication-react-native
62-
```
63-
64-
Next, install SQLite3 engine modules:
65-
66-
```bash
67-
npm i pouchdb-adapter-react-native-sqlite react-native-sqlite-2
68-
react-native link react-native-sqlite-2
69-
```
70-
71-
Then, install some packages to polyfill functions that PouchDB needs:
72-
73-
```bash
74-
npm i base-64 events
75-
```
76-
77-
### Create polyfills
78-
79-
Make a js file to polyfill some functions that PouchDB needs:
80-
81-
```js
82-
import {decode, encode} from 'base-64'
83-
84-
if (!global.btoa) {
85-
global.btoa = encode;
86-
}
87-
88-
if (!global.atob) {
89-
global.atob = decode;
90-
}
91-
92-
// Avoid using node dependent modules
93-
process.browser = true
94-
```
95-
96-
Import it at the first line of your `index.js`.
97-
98-
### Load PouchDB
99-
100-
Make `pouchdb.js` like so:
101-
102-
```js
103-
import PouchDB from '@craftzdog/pouchdb-core-react-native'
104-
import HttpPouch from 'pouchdb-adapter-http'
105-
import replication from '@craftzdog/pouchdb-replication-react-native'
106-
import mapreduce from 'pouchdb-mapreduce'
107-
108-
import SQLite from 'react-native-sqlite-2'
109-
import SQLiteAdapterFactory from 'pouchdb-adapter-react-native-sqlite'
110-
111-
const SQLiteAdapter = SQLiteAdapterFactory(SQLite)
112-
113-
export default PouchDB
114-
.plugin(HttpPouch)
115-
.plugin(replication)
116-
.plugin(mapreduce)
117-
.plugin(SQLiteAdapter)
118-
```
119-
120-
If you need other plugins like `pouchdb-find`, just add them to it.
121-
122-
### Use PouchDB
123-
124-
Then, use it as usual:
125-
126-
```js
127-
import PouchDB from './pouchdb'
128-
129-
function loadDB () {
130-
return new PouchDB('mydb.db', { adapter: 'react-native-sqlite' })
131-
}
132-
```
46+
Check out the [craftzdog/pouchdb-react-native](https://github.com/craftzdog/pouchdb-react-native) repository.
13347

13448
## Changelog
13549

50+
- 3.0.1
51+
- Fix dependency and import
52+
- 3.0.0
53+
- Use [@craftzdog/pouchdb-adapter-websql-core](https://github.com/craftzdog/pouchdb-adapter-websql-core) #11
13654
- 2.0.0
137-
+ Upgrade pouchdb-adapter-websql-core to 7.0.0
55+
- Upgrade pouchdb-adapter-websql-core to 7.0.0
13856
- 1.0.3
139-
+ Remove `pouchdb-utils` dependency
57+
- Remove `pouchdb-utils` dependency
14058
- 1.0.2
141-
+ Upgrade pouchdb-util & pouchdb-adapter-websql-core to 6.2.0
142-
+ Update benchmark result
59+
- Upgrade pouchdb-util & pouchdb-adapter-websql-core to 6.2.0
60+
- Update benchmark result
14361
- 1.0.1
144-
+ Remove unnecessary console output
62+
- Remove unnecessary console output
14563
- 1.0.0
146-
+ Initial release
64+
- Initial release

0 commit comments

Comments
 (0)