1
0
mirror of https://github.com/nolanlawson/pinafore synced 2025-01-10 10:16:20 +01:00
Pinafore-Web-Client-Frontend/routes/_utils/database/knownDbs.js

21 lines
628 B
JavaScript
Raw Normal View History

2018-01-22 02:18:56 +01:00
import keyval from "idb-keyval"
export async function addKnownDb(instanceName, type, dbName) {
let knownDbs = (await keyval.get('known_dbs')) || {}
if (!knownDbs[instanceName]) {
knownDbs[instanceName] = []
}
if (!knownDbs[instanceName].some(db => db.type === type && db.dbName === dbName)) {
knownDbs[instanceName].push({type, dbName})
}
await keyval.set('known_dbs', knownDbs)
}
export async function getKnownDbs() {
return (await keyval.get('known_dbs')) || {}
}
export async function getKnownDbsForInstance(instanceName) {
let knownDbs = await getKnownDbs()
return knownDbs[instanceName] || []
}