import { isFullString } from 'is-what' ; import { PluginDeleteAction , PluginDeleteActionPayload } from '@magnetarjs/core' ; import { SimpleStoreModuleConfig , SimpleStoreOptions , MakeRestoreBackup } from '../CreatePlugin' ; export function deleteActionFactory ( data , simpleStoreOptions , makeBackup ? ) { return function ( { payload , collectionPath , docId , pluginModuleConfig , } ) : void { const _docId = docId || payload ; if ( ! isFullString ( _docId ) ) throw new Error ( 'No ID passed to delete action.' ) ; if ( makeBackup ) makeBackup ( collectionPath , _docId ) ; data [ collectionPath ] . delete ( _docId ) ; } ; }