bfx-hf-models-adapter-lowdb
Version:
LowDB adapter for the HF database
19 lines (13 loc) • 434 B
JavaScript
const ensureMap = require('../util/ensure_map')
const idFromDocOrID = require('../util/id_from_doc_or_id')
module.exports = async (db, { mapKey, path }, docOrID) => {
ensureMap(db, path)
const id = idFromDocOrID(mapKey, docOrID)
const fullPath = `${path}.${id}`
const v = db.get(fullPath).value()
if (!v) {
throw new Error(`value does not exist: ${fullPath}`)
}
db.unset(`${path}.${id}`).write()
}