1
0
Fork 0
mirror of synced 2024-06-02 02:25:17 +12:00
budibase/packages/worker/src/db/index.js

27 lines
630 B
JavaScript
Raw Normal View History

const PouchDB = require("pouchdb")
const allDbs = require("pouchdb-all-dbs")
const env = require("../environment")
const { getCouchUrl } = require("@budibase/backend-core/db")
// level option is purely for testing (development)
2022-02-19 06:36:23 +13:00
const COUCH_DB_URL = getCouchUrl() || "http://localhost:4005"
let POUCH_DB_DEFAULTS = {
prefix: COUCH_DB_URL,
}
if (env.isTest()) {
PouchDB.plugin(require("pouchdb-adapter-memory"))
POUCH_DB_DEFAULTS = {
prefix: undefined,
adapter: "memory",
}
}
const Pouch = PouchDB.defaults(POUCH_DB_DEFAULTS)
// have to still have pouch alldbs for testing
allDbs(Pouch)
2021-01-15 06:02:05 +13:00
module.exports = Pouch