function saveKeyValues(view, docIdsToChangesAndEmits, seq) {
    var seqDocId = '_local/lastSeq';
    return view.db.get(seqDocId)[
      "catch"](defaultsTo({_id: seqDocId, seq: 0}))
      .then(function (lastSeqDoc) {
        var docIds = mapToKeysArray(docIdsToChangesAndEmits);
        return PouchPromise$1.all(docIds.map(function (docId) {
          return getDocsToPersist(docId, view, docIdsToChangesAndEmits);
        })).then(function (listOfDocsToPersist) {
          var docsToPersist = flatten(listOfDocsToPersist);
          lastSeqDoc.seq = seq;
          docsToPersist.push(lastSeqDoc);
          // write all docs in a single operation, update the seq once
          return view.db.bulkDocs({docs : docsToPersist});
        });
      });
  }
// for the given batch of documents from the source database
for the given batch of documents from the source database
for the given batch of documents from the source database
function saveKeyValues(view, docIdsToChangesAndEmits, seq) {
    var seqDocId = '_local/lastSeq';
    return view.db.get(seqDocId)[
      "catch"](defaultsTo({_id: seqDocId, seq: 0}))
      .then(function (lastSeqDoc) {
        var docIds = mapToKeysArray(docIdsToChangesAndEmits);
        return PouchPromise$1.all(docIds.map(function (docId) {
          return getDocsToPersist(docId, view, docIdsToChangesAndEmits);
        })).then(function (listOfDocsToPersist) {
          var docsToPersist = flatten(listOfDocsToPersist);
          lastSeqDoc.seq = seq;
          docsToPersist.push(lastSeqDoc);
          return view.db.bulkDocs({docs : docsToPersist});
        });
      });
  }
function saveKeyValues ( view , docIdsToChangesAndEmits , seq ) { var seqDocId = '_local/lastSeq' ; return view . db . get ( seqDocId ) [ "catch" ] ( defaultsTo ( { _id : seqDocId , seq : 0 } ) ) . then ( function ( lastSeqDoc ) { var docIds = mapToKeysArray ( docIdsToChangesAndEmits ) ; return PouchPromise$1 . all ( docIds . map ( function ( docId ) { return getDocsToPersist ( docId , view , docIdsToChangesAndEmits ) ; } ) ) . then ( function ( listOfDocsToPersist ) { var docsToPersist = flatten ( listOfDocsToPersist ) ; lastSeqDoc . seq = seq ; docsToPersist . push ( lastSeqDoc ) ; return view . db . bulkDocs ( { docs : docsToPersist } ) ; } ) ; } ) ; }
for the given batch of documents from the source database
for the given batch of documents from the source database
// write all docs in a single operation, update the seq once