Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* global PouchDB */
import MemoryPouchPlugin from 'pouchdb-adapter-memory';
import { guardedConsole } from 'pouchdb-utils';
var PDB = (typeof PouchDB !== 'undefined') ? PouchDB : require('pouchdb');
if (!PDB) {
guardedConsole('error', 'memory adapter plugin error: ' +
'Cannot find global "PouchDB" object! ' +
'Did you remember to include pouchdb.js?');
} else {
MemoryPouchPlugin(PDB);
}
import PouchDB from 'pouchdb-core'
// All Environments
let configuredPouch = PouchDB
.plugin(require('pouchdb-find').default)
if(process.env["NODE_ENV"] === 'test' && typeof window === 'undefined') {
// Node tests, include extra libs for speed
configuredPouch
.plugin(require('pouchdb-adapter-memory').default)
configuredPouch = configuredPouch.defaults({ adapter: 'memory' })
} else {
// Any environment with a window
configuredPouch
.plugin(require('pouchdb-adapter-idb').default)
.plugin(require('pouchdb-adapter-websql').default)
}
export default configuredPouch