2020-04-24 10:54:20 +02:00
|
|
|
const PouchDB = require("pouchdb")
|
2020-04-25 09:35:34 +02:00
|
|
|
const allDbs = require("pouchdb-all-dbs")
|
2020-05-07 11:53:34 +02:00
|
|
|
const os = require("os")
|
|
|
|
const path = require("path")
|
2020-04-07 16:12:08 +02:00
|
|
|
|
2020-05-07 11:53:34 +02:00
|
|
|
const BUDIBASE_DIR = path.join(os.homedir(), ".budibase")
|
2020-04-28 15:39:35 +02:00
|
|
|
|
2020-05-07 11:53:34 +02:00
|
|
|
const COUCH_DB_URL = process.env.COUCH_DB_URL || `leveldb://${BUDIBASE_DIR}/`
|
|
|
|
const DATABASE_TYPE = process.env.DATABASE_TYPE || "couch"
|
2020-04-28 15:39:35 +02:00
|
|
|
|
|
|
|
const Pouch = PouchDB.defaults({
|
|
|
|
prefix: COUCH_DB_URL,
|
2020-05-07 11:53:34 +02:00
|
|
|
})
|
2020-04-28 15:39:35 +02:00
|
|
|
|
2020-05-07 11:53:34 +02:00
|
|
|
allDbs(Pouch)
|
2020-04-28 15:39:35 +02:00
|
|
|
|
2020-05-07 11:53:34 +02:00
|
|
|
module.exports = Pouch
|