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 Sep 25, 2024
1 parent 9edfd8b commit 6f9d3ec
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions __tests__/jestSetupFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,5 @@ jest.mock('../src/core/tools/env', () => ({
shouldDisableAutolock: jest.fn().mockReturnValue(false)
}))

jest.mock('../src/pouchdb/pouchdb', () => ({}))
jest.mock('react-native-quick-websql', () => ({}))
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 6f9d3ec

Please sign in to comment.