src/common/idb.js
function updateItem(id, updater) {
  return new Promise((resolve, reject) => {
    return instance.pkgs.then(db => {
      const obj = db.transaction(db.name, 'readwrite')
        .objectStore(db.name);
      const req = obj.get(id);
      req.onerror = event => reject(event);
      req.onsuccess = event => {
        const res = event.target.result;
        updater(res);
        const upd = obj.put(res);
        upd.onsuccess = () => resolve();
        upd.onerror = event => reject(event);
      };
    });
  });
}
function updateItem(id, updater) {
  return new Promise((resolve, reject) => {
    return instance.pkgs.then(db => {
      const obj = db.transaction(db.name, 'readwrite')
        .objectStore(db.name);
      const req = obj.get(id);
      req.onerror = event => reject(event);
      req.onsuccess = event => {
        const res = event.target.result;
        updater(res);
        const upd = obj.put(res);
        upd.onsuccess = () => resolve();
        upd.onerror = event => reject(event);
      };
    });
  });
}
function updateItem ( id , updater ) { return new Promise ( ( resolve , reject ) => { return instance . pkgs . then ( db => { const obj = db . transaction ( db . name , 'readwrite' ) . objectStore ( db . name ) ; const req = obj . get ( id ) ; req . onerror = event => reject ( event ) ; req . onsuccess = event => { const res = event . target . result ; updater ( res ) ; const upd = obj . put ( res ) ; upd . onsuccess = ( ) => resolve ( ) ; upd . onerror = event => reject ( event ) ; } ; } ) ; } ) ; }
Update package in the store
@param {string} id - Package instance ID
@param {function} updater - update function
Update package in the store