(view, docIdsToChangesAndEmits, seq)
| 8532 | // updates all emitted key/value docs and metaDocs in the mrview database |
| 8533 | // for the given batch of documents from the source database |
| 8534 | function saveKeyValues(view, docIdsToChangesAndEmits, seq) { |
| 8535 | var seqDocId = '_local/lastSeq'; |
| 8536 | return view.db.get(seqDocId) |
| 8537 | .catch(defaultsTo({_id: seqDocId, seq: 0})) |
| 8538 | .then(function (lastSeqDoc) { |
| 8539 | var docIds = mapToKeysArray(docIdsToChangesAndEmits); |
| 8540 | return Promise.all(docIds.map(function (docId) { |
| 8541 | return getDocsToPersist(docId, view, docIdsToChangesAndEmits); |
| 8542 | })).then(function (listOfDocsToPersist) { |
| 8543 | var docsToPersist = listOfDocsToPersist.flat(); |
| 8544 | lastSeqDoc.seq = seq; |
| 8545 | docsToPersist.push(lastSeqDoc); |
| 8546 | // write all docs in a single operation, update the seq once |
| 8547 | return view.db.bulkDocs({docs : docsToPersist}); |
| 8548 | }) |
| 8549 | // TODO: this should be placed somewhere else, probably? we're querying both docs twice |
| 8550 | // (first time when getting the actual purges). |
| 8551 | .then(() => updatePurgeSeq(view)); |
| 8552 | }); |
| 8553 | } |
| 8554 | |
| 8555 | function getQueue(view) { |
| 8556 | const viewName = typeof view === 'string' ? view : view.name; |
no test coverage detected
searching dependent graphs…