Skip to content

Commit

Permalink
feat: Configure PouchDB to run on the project
Browse files Browse the repository at this point in the history
  • Loading branch information
Ldoppea committed May 28, 2024
1 parent bd0d17b commit d59cd3e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import '/pouchdb/shim'

import { AppRegistry } from 'react-native'

import App from './App'
Expand Down
16 changes: 16 additions & 0 deletions src/pouchdb/pouchdb.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// eslint-disable-next-line import/order
import 'react-native-get-random-values'

import HttpPouch from 'pouchdb-adapter-http'
import SQLiteAdapterFactory from 'pouchdb-adapter-react-native-sqlite'
import PouchDB from 'pouchdb-core'
import mapreduce from 'pouchdb-mapreduce'
import replication from 'pouchdb-replication'
import WebSQLite from 'react-native-quick-websql'

const SQLiteAdapter = SQLiteAdapterFactory(WebSQLite)

export default PouchDB.plugin(HttpPouch)
.plugin(replication)
.plugin(mapreduce)
.plugin(SQLiteAdapter)
6 changes: 6 additions & 0 deletions src/pouchdb/shim.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { shim } from 'react-native-quick-base64'

shim()

// Avoid using node dependent modules
process.browser = true

0 comments on commit d59cd3e

Please sign in to comment.