dobo
Version:
Database ORM/ODM for Bajo Framework
14 lines (11 loc) • 449 B
JavaScript
import getRecord from './get.js'
async function remove ({ schema, id, options = {} }) {
const { noResult } = options
const { findIndex, pullAt } = this.lib._
const rec = noResult ? undefined : await getRecord.call(this, { schema, id })
const idx = findIndex(this.memDb.storage[schema.name], { id })
pullAt(this.memDb.storage[schema.name], [idx])
if (noResult) return
return { oldData: rec.data }
}
export default remove