From 16166ba843f422c4c2789bbbd72c86552e0d4ea2 Mon Sep 17 00:00:00 2001 From: PikachuEXE Date: Fri, 28 Jan 2022 23:18:02 +0800 Subject: [PATCH] Cleanup/duplicate datastore module (#2023) * - Remove duplicate datastore file Which is not referenced and comes from old PR * - Remove unncessary index --- src/datastores/index.js | 2 +- src/renderer/store/datastores.js | 51 -------------------------------- 2 files changed, 1 insertion(+), 52 deletions(-) delete mode 100644 src/renderer/store/datastores.js diff --git a/src/datastores/index.js b/src/datastores/index.js index 879ec199..11e1c5a2 100644 --- a/src/datastores/index.js +++ b/src/datastores/index.js @@ -20,5 +20,5 @@ db.history = Datastore.create({ filename: dbPath('history'), autoload: true }) db.history.ensureIndex({ fieldName: 'author' }) db.history.ensureIndex({ fieldName: 'title' }) -db.history.ensureIndex({ fieldName: 'videoId' }) + export default db diff --git a/src/renderer/store/datastores.js b/src/renderer/store/datastores.js deleted file mode 100644 index 3f1bd234..00000000 --- a/src/renderer/store/datastores.js +++ /dev/null @@ -1,51 +0,0 @@ -import Datastore from 'nedb-promises' - -// Initialize all datastores and export their references -// Current dbs: -// `settings.db` -// `profiles.db` -// `playlists.db` -// `history.db` - -let buildFileName = null - -// Check if using Electron -const usingElectron = window?.process?.type === 'renderer' -if (usingElectron) { - const { ipcRenderer } = require('electron') - const userDataPath = ipcRenderer.sendSync('getUserDataPathSync') - buildFileName = (dbName) => userDataPath + '/' + dbName + '.db' -} else { - buildFileName = (dbName) => dbName + '.db' -} - -const settingsDb = Datastore.create({ - filename: buildFileName('settings'), - autoload: true -}) - -const playlistsDb = Datastore.create({ - filename: buildFileName('playlists'), - autoload: true -}) - -const profilesDb = Datastore.create({ - filename: buildFileName('profiles'), - autoload: true -}) - -const historyDb = Datastore.create({ - filename: buildFileName('history'), - autoload: true -}) - -historyDb.ensureIndex({ fieldName: 'author' }) -historyDb.ensureIndex({ fieldName: 'title' }) -historyDb.ensureIndex({ fieldName: 'videoId' }) - -export { - settingsDb, - profilesDb, - playlistsDb, - historyDb -}