From 8815f86dd7dc8aad62d8b49018d90114b9295551 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=ABck=20V=C3=A9zien?= Date: Wed, 17 Jan 2018 16:24:11 +0100 Subject: [PATCH] New DB storage --- src/helpers/db.js | 26 ++++++++++++++++++++++---- src/middlewares/db.js | 2 +- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/helpers/db.js b/src/helpers/db.js index db4ecf52..d8217188 100644 --- a/src/helpers/db.js +++ b/src/helpers/db.js @@ -1,7 +1,25 @@ import Store from 'electron-store' -const store = new Store({ - // encryptionKey: 'toto', -}) +export default { + accounts: () => { + const db = new Store({ + name: 'accounts', + default: { + accounts: [], + }, + }) -export default store + return { + get: db.get('accounts'), + set: accounts => db.get('accounts', accounts), + } + }, + settings: () => { + const db = new Store({ + name: 'settings', + default: {}, + }) + + return db + }, +} diff --git a/src/middlewares/db.js b/src/middlewares/db.js index caba1de8..9e69c767 100644 --- a/src/middlewares/db.js +++ b/src/middlewares/db.js @@ -13,5 +13,5 @@ export default store => next => action => { const { accounts } = getState() - db.set('accounts', accounts.accounts) + db.accounts.set(accounts.accounts) }