diff --git a/src/datastores/index.js b/src/datastores/index.js index 879ec1994..11e1c5a2f 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 3f1bd234f..000000000 --- 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 -}