SHARE
TWEET

Untitled

a guest Jun 20th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function func( callBack ) {
  2.     let T = DB_open.base.transaction( ['notes'], 'readwrite' ),
  3.         n = T.objectStore( 'notes' ),
  4.         k = IDBKeyRange.bound( [ selKey, 0 ], [ selKey + 1, 0 ], false, true ),
  5.         req;
  6.  
  7.      T.oncomplete = (e) => { if ( callBack ) callBack(); };
  8.      T.onerror = (e) => { e.stopPropagation(); };
  9.      try {
  10.          /* Preparatory code */
  11.          if ( condition_1 ) {
  12.              n.openCursor( k ).onsuccess = ( e ) => {
  13.                  let v, cursor = e.target.result;
  14.                  if ( cursor ) {
  15.                      v = cursor.value;
  16.                      if ( condition_2 ) {
  17.                          /* A few lines of non-database code */
  18.                          cursor.update( v );  
  19.                        }; // end if
  20.                      cursor.continue();
  21.                    }; // end if cursor
  22.                }; // close cursor onsuccess
  23.            }
  24.          else {
  25.              req = n.get( [ a, b ] );
  26.              req.onsuccess = function()
  27.               {
  28.                 /* A few lines of code */
  29.                 n.put( r );
  30.               }; // close req_c
  31.            }; // end if
  32.  
  33.          if ( callBack ) {
  34.              /* A few lines of non-database code */
  35.              n.put ( { 'key' : [0,0], .... } );
  36.              n.add ( { 'key' : [selKey, 0], ... } );
  37.           }; // end if
  38.        } // close try  
  39.      catch { T.abort(); }
  40.   }  // close func
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top