UNPKG

bfx-hf-models-adapter-lowdb

Version:
19 lines (13 loc) 434 B
'use strict' 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() }