src/common/idb.js
function deleteView(id, viewID) {
  return updateItem(id, item => {
    const pos = item.views.findIndex(e => e.viewID === viewID);
    item.views.splice(pos, 1);
    // prune orphaned collections
    const bin = {};
    item.dataset.forEach(e => { bin[e.collectionID] = 0; });
    item.views.forEach(view => {
      ['rows', 'items', 'nodes', 'edges']
        .filter(e => view.hasOwnProperty(e))
        .forEach(e => { bin[view[e]] += 1; });
    });
    Object.entries(bin).forEach(entry => {
      if (!entry[1]) {
        const i = item.dataset.findIndex(e => e.collectionID === entry[0]);
        item.dataset.splice(i, 1);
      }
    });
  });
}
function deleteView(id, viewID) {
  return updateItem(id, item => {
    const pos = item.views.findIndex(e => e.viewID === viewID);
    item.views.splice(pos, 1);
    // prune orphaned collections
    const bin = {};
    item.dataset.forEach(e => { bin[e.collectionID] = 0; });
    item.views.forEach(view => {
      ['rows', 'items', 'nodes', 'edges']
        .filter(e => view.hasOwnProperty(e))
        .forEach(e => { bin[view[e]] += 1; });
    });
    Object.entries(bin).forEach(entry => {
      if (!entry[1]) {
        const i = item.dataset.findIndex(e => e.collectionID === entry[0]);
        item.dataset.splice(i, 1);
      }
    });
  });
}
function deleteView ( id , viewID ) { return updateItem ( id , item => { const pos = item . views . findIndex ( e => e . viewID === viewID ) ; item . views . splice ( pos , 1 ) ; // prune orphaned collections const bin = { } ; item . dataset . forEach ( e => { bin [ e . collectionID ] = 0 ; } ) ; item . views . forEach ( view => { [ 'rows' , 'items' , 'nodes' , 'edges' ] . filter ( e => view . hasOwnProperty ( e ) ) . forEach ( e => { bin [ view [ e ] ] += 1 ; } ) ; } ) ; Object . entries ( bin ) . forEach ( entry => { if ( ! entry [ 1 ] ) { const i = item . dataset . findIndex ( e => e . collectionID === entry [ 0 ] ) ; item . dataset . splice ( i , 1 ) ; } } ) ; } ) ; }
Delete a data object from the store
@param {string} id - Package instance ID
@return {integer} - number of deleted items
Delete a data object from the store