-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch database from PouchDB to NeDB (also persist Slack tokens)
This was because PounchDB required the database code to be run in the render threads, which was annoying. NeDB allows running from the main thread or the render threads. Most of the time, I want it to run from the main thread. Resolves #52 Also, whilst testing NeDB - we're also storing the Slack authtokens. Note that at this stage, they're being stored in plain text. Need to look into the best way of storing them. Issue #16 related to Slack integration.
- Loading branch information
Showing
8 changed files
with
220 additions
and
1,100 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ src/dist/ | |
tools/ | ||
tomatoad.*.nupkg | ||
!Chocolatey/tools/ | ||
src/db/ |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,34 @@ | ||
var PouchDB = require('pouchdb'); | ||
PouchDB.plugin(require('pouchdb-adapter-idb')) | ||
var Datastore = require('nedb') | ||
|
||
var db = new PouchDB('tomatoad_test', { adapter: 'idb' }) | ||
const dbSlack = new Datastore({ filename: __dirname + '/../db/slack.json', autoload: true }); | ||
|
||
dbSlack.persistence.compactDatafile() | ||
|
||
module.exports = { | ||
saveNewPomodoro: function (callback) { | ||
/* | ||
var pomodoro = { | ||
_id: new Date().toISOString(), | ||
completed: false | ||
} | ||
db.put(pomodoro, function callback(err, result) { | ||
if (!err) { | ||
console.log('Successfully saved a pomodoro!'); | ||
} | ||
}) | ||
db.insert(pomodoro, function (err, newDoc) { // Callback is optional | ||
// newDoc is the newly inserted document, including its _id | ||
// newDoc has no key called notToBeSaved since its value was undefined | ||
}); | ||
*/ | ||
}, | ||
|
||
saveSlackAuthTokens(authTokens) { | ||
dbSlack.update({ | ||
_id: 'slackAuthTokens' | ||
}, { _id: 'slackAuthTokens', data: authTokens }, { upsert: true }, function (err, numReplaced, upsert) { | ||
}); | ||
}, | ||
|
||
loadSlackAuthTokens(callback) { | ||
dbSlack.find({ _id: 'slackAuthTokens' }, function (err, docs) { | ||
callback(docs.length == 0 ? {} : docs[0].data) | ||
}); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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
Oops, something went wrong.