function migrateLocalStore(txn, cb) {
    var localStore = txn.objectStore(LOCAL_STORE);
    var docStore = txn.objectStore(DOC_STORE);
    var seqStore = txn.objectStore(BY_SEQ_STORE);

    var cursor = docStore.openCursor();
    cursor.onsuccess = function (event) {
      var cursor = event.target.result;
      if (cursor) {
        var metadata = cursor.value;
        var docId = metadata.id;
        var local = isLocalId(docId);
        var rev$$1 = winningRev(metadata);
        if (local) {
          var docIdRev = docId + "::" + rev$$1;
          // remove all seq entries
          // associated with this docId
          var start = docId + "::";
          var end = docId + "::~";
          var index = seqStore.index('_doc_id_rev');
          var range = IDBKeyRange.bound(start, end, false, false);
          var seqCursor = index.openCursor(range);
          seqCursor.onsuccess = function (e) {
            seqCursor = e.target.result;
            if (!seqCursor) {
              // done
              docStore["delete"](cursor.primaryKey);
              cursor["continue"]();
            } else {
              var data = seqCursor.value;
              if (data._doc_id_rev === docIdRev) {
                localStore.put(data);
              }
              seqStore["delete"](seqCursor.primaryKey);
              seqCursor["continue"]();
            }
          };
        } else {
          cursor["continue"]();
        }
      } else if (cb) {
        cb();
      }
    };
  }
// migration to version 3 (part 2)
migration to version 3 (part 2)
migration to version 3 ( part 2 )
function migrateLocalStore(txn, cb) {
    var localStore = txn.objectStore(LOCAL_STORE);
    var docStore = txn.objectStore(DOC_STORE);
    var seqStore = txn.objectStore(BY_SEQ_STORE);
    var cursor = docStore.openCursor();
    cursor.onsuccess = function (event) {
      var cursor = event.target.result;
      if (cursor) {
        var metadata = cursor.value;
        var docId = metadata.id;
        var local = isLocalId(docId);
        var rev$$1 = winningRev(metadata);
        if (local) {
          var docIdRev = docId + "::" + rev$$1;
          var start = docId + "::";
          var end = docId + "::~";
          var index = seqStore.index('_doc_id_rev');
          var range = IDBKeyRange.bound(start, end, false, false);
          var seqCursor = index.openCursor(range);
          seqCursor.onsuccess = function (e) {
            seqCursor = e.target.result;
            if (!seqCursor) {
              docStore["delete"](cursor.primaryKey);
              cursor["continue"]();
            } else {
              var data = seqCursor.value;
              if (data._doc_id_rev === docIdRev) {
                localStore.put(data);
              }
              seqStore["delete"](seqCursor.primaryKey);
              seqCursor["continue"]();
            }
          };
        } else {
          cursor["continue"]();
        }
      } else if (cb) {
        cb();
      }
    };
  }
function migrateLocalStore ( txn , cb ) { var localStore = txn . objectStore ( LOCAL_STORE ) ; var docStore = txn . objectStore ( DOC_STORE ) ; var seqStore = txn . objectStore ( BY_SEQ_STORE ) ; var cursor = docStore . openCursor ( ) ; cursor . onsuccess = function ( event ) { var cursor = event . target . result ; if ( cursor ) { var metadata = cursor . value ; var docId = metadata . id ; var local = isLocalId ( docId ) ; var rev$$1 = winningRev ( metadata ) ; if ( local ) { var docIdRev = docId + "::" + rev$$1 ; var start = docId + "::" ; var end = docId + "::~" ; var index = seqStore . index ( '_doc_id_rev' ) ; var range = IDBKeyRange . bound ( start , end , false , false ) ; var seqCursor = index . openCursor ( range ) ; seqCursor . onsuccess = function ( e ) { seqCursor = e . target . result ; if ( ! seqCursor ) { docStore [ "delete" ] ( cursor . primaryKey ) ; cursor [ "continue" ] ( ) ; } else { var data = seqCursor . value ; if ( data . _doc_id_rev === docIdRev ) { localStore . put ( data ) ; } seqStore [ "delete" ] ( seqCursor . primaryKey ) ; seqCursor [ "continue" ] ( ) ; } } ; } else { cursor [ "continue" ] ( ) ; } } else if ( cb ) { cb ( ) ; } } ; }
migration to version 3 (part 2)
migration to version 3 ( part 2 )
// remove all seq entries // associated with this docId // done