From 9fda6e79cfd9356f7b8c27daa9b1db71054fc84b Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Wed, 27 Apr 2016 16:33:38 -0700 Subject: [PATCH] Write DB to application directory --- .gitignore | 3 --- app/database/index.js | 6 +++++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 5000a8d47..1aab60d90 100644 --- a/.gitignore +++ b/.gitignore @@ -3,9 +3,6 @@ node_modules dist/* build/* -# PouchDB stuff -*db.json - # Logs logs *.log diff --git a/app/database/index.js b/app/database/index.js index 0bb60bf66..d2798d9e0 100644 --- a/app/database/index.js +++ b/app/database/index.js @@ -1,3 +1,6 @@ +import * as fsPath from 'path' +import electron from 'electron' + // import PouchDB from 'pouchdb'; import * as methods from '../lib/constants'; import {generateId} from './util' @@ -28,7 +31,8 @@ export function initDB () { } return new Promise(resolve => { - db = new Loki('insomnia.db.json', { + const rootPath = electron.remote.app.getPath('appData'); + db = new Loki(fsPath.join(rootPath, 'insomnia.db.json'), { autoload: true, autosave: true, autosaveInterval: 500, // TODO: Make this a bit smarter maybe