Last active
July 6, 2016 19:09
-
-
Save singhshashi/06d866e76e4b77dba989dded9e53d328 to your computer and use it in GitHub Desktop.
Configuring PouchDB with LevelDB to store data within User's Home folder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//When using pouchDB within your Electron app, you may want to use different locations for the DB file during development vs releasing the app. | |
//When distributing the app, you would want to store the data within the $HOME/.config/YourApp/data as per convention on Ubuntu. | |
//to access the environment variable HOME in the renderer process. See https://github.com/electron/electron/issues/3306 | |
const remote = require('electron').remote; | |
//we cannot use ~ in the path of leveldb as that is not correct way. See https://github.com/Level/levelup/issues/120. Thus use env.HOME | |
let dbFilePath = remote.process.env.HOME + '/.config/myapp/data/'; | |
if (process.env.NODE_ENV === 'development') { | |
dbFilePath = './data/'; | |
} | |
let db = new PouchDB(dbFilePath); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment