MCPcopy Index your code
hub / github.com/apache/pouchdb / saveKeyValues

Function saveKeyValues

lib/index.js:8572–8591  ·  view source on GitHub ↗
(view, docIdsToChangesAndEmits, seq)

Source from the content-addressed store, hash-verified

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

Callers 1

processChangeFunction · 0.70

Calls 5

defaultsToFunction · 0.70
mapToKeysArrayFunction · 0.70
getDocsToPersistFunction · 0.70
updatePurgeSeqFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…