This commit is contained in:
Josh Harvey 2016-10-09 18:49:13 +01:00
parent f62e65fe93
commit bd3441adfb
4 changed files with 43 additions and 21 deletions

View file

@ -9,19 +9,31 @@ exports.connect = connect
function load () {
var db = connect()
return db.one('select data from user_config where type=$1', 'exchanges')
return db.one('select data from user_config where type=$1', 'config')
.then(function (data) {
pgp.end()
return data.data
})
}
function loadAccounts () {
const toFields = fieldArr => R.fromPairs(R.map(r => [r.code, r.value], fieldArr))
const toPairs = r => [r.code, toFields(r.fields)]
var db = connect()
return db.one('select data from user_config where type=$1', 'accounts')
.then(function (data) {
pgp.end()
return R.fromPairs(R.map(toPairs, data.data.accounts))
})
}
module.exports = {
load,
unscoped,
cryptoScoped,
machineScoped,
scoped
scoped,
loadAccounts
}
function matchesValue (crypto, machine, instance) {