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

Function processKeyValueDocs

lib/index-browser.es.js:8461–8498  ·  view source on GitHub ↗
(metaDoc, kvDocsRes)

Source from the content-addressed store, hash-verified

8459 }
8460
8461 function processKeyValueDocs(metaDoc, kvDocsRes) {
8462 const kvDocs = [];
8463 const oldKeys = new Set();
8464
8465 for (const row of kvDocsRes.rows) {
8466 const doc = row.doc;
8467 if (!doc) { // deleted
8468 continue;
8469 }
8470 kvDocs.push(doc);
8471 oldKeys.add(doc._id);
8472 doc._deleted = !indexableKeysToKeyValues.has(doc._id);
8473 if (!doc._deleted) {
8474 const keyValue = indexableKeysToKeyValues.get(doc._id);
8475 if ('value' in keyValue) {
8476 doc.value = keyValue.value;
8477 }
8478 }
8479 }
8480 const newKeys = mapToKeysArray(indexableKeysToKeyValues);
8481 for (const key of newKeys) {
8482 if (!oldKeys.has(key)) {
8483 // new doc
8484 const kvDoc = {
8485 _id: key
8486 };
8487 const keyValue = indexableKeysToKeyValues.get(key);
8488 if ('value' in keyValue) {
8489 kvDoc.value = keyValue.value;
8490 }
8491 kvDocs.push(kvDoc);
8492 }
8493 }
8494 metaDoc.keys = uniq(newKeys.concat(metaDoc.keys));
8495 kvDocs.push(metaDoc);
8496
8497 return kvDocs;
8498 }
8499
8500 const metaDoc = await getMetaDoc();
8501 const keyValueDocs = await getKeyValueDocs(metaDoc);

Callers 1

getDocsToPersistFunction · 0.70

Calls 4

mapToKeysArrayFunction · 0.70
uniqFunction · 0.70
addMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…