(view, docIdsToChangesAndEmits, seq)
| 8565 | // updates all emitted key/value docs and metaDocs in the mrview database |
| 8566 | // for the given batch of documents from the source database |
| 8567 | function saveKeyValues(view, docIdsToChangesAndEmits, seq) { |
| 8568 | var seqDocId = '_local/lastSeq'; |
| 8569 | return view.db.get(seqDocId) |
| 8570 | .catch(defaultsTo({_id: seqDocId, seq: 0})) |
| 8571 | .then(function (lastSeqDoc) { |
| 8572 | var docIds = mapToKeysArray(docIdsToChangesAndEmits); |
| 8573 | return Promise.all(docIds.map(function (docId) { |
| 8574 | return getDocsToPersist(docId, view, docIdsToChangesAndEmits); |
| 8575 | })).then(function (listOfDocsToPersist) { |
| 8576 | var docsToPersist = listOfDocsToPersist.flat(); |
| 8577 | lastSeqDoc.seq = seq; |
| 8578 | docsToPersist.push(lastSeqDoc); |
| 8579 | // write all docs in a single operation, update the seq once |
| 8580 | return view.db.bulkDocs({docs : docsToPersist}); |
| 8581 | }) |
| 8582 | // TODO: this should be placed somewhere else, probably? we're querying both docs twice |
| 8583 | // (first time when getting the actual purges). |
| 8584 | .then(() => updatePurgeSeq(view)); |
| 8585 | }); |
| 8586 | } |
| 8587 | |
| 8588 | function getQueue(view) { |
| 8589 | const viewName = typeof view === 'string' ? view : view.name; |
no test coverage detected
searching dependent graphs…