Cleanup/duplicate datastore module (#2023)

* - Remove duplicate datastore file

Which is not referenced and comes from old PR

* - Remove unncessary index
This commit is contained in:
PikachuEXE 2022-01-28 23:18:02 +08:00 committed by GitHub
parent 8bacacc870
commit 16166ba843
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 52 deletions

View File

@ -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

View File

@ -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
}