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

Function processKeyValueDocs

lib/index.js:8503–8540  ·  view source on GitHub ↗
(metaDoc, kvDocsRes)

Source from the content-addressed store, hash-verified

8501 }
8502
8503 function processKeyValueDocs(metaDoc, kvDocsRes) {
8504 const kvDocs = [];
8505 const oldKeys = new Set();
8506
8507 for (const row of kvDocsRes.rows) {
8508 const doc = row.doc;
8509 if (!doc) { // deleted
8510 continue;
8511 }
8512 kvDocs.push(doc);
8513 oldKeys.add(doc._id);
8514 doc._deleted = !indexableKeysToKeyValues.has(doc._id);
8515 if (!doc._deleted) {
8516 const keyValue = indexableKeysToKeyValues.get(doc._id);
8517 if ('value' in keyValue) {
8518 doc.value = keyValue.value;
8519 }
8520 }
8521 }
8522 const newKeys = mapToKeysArray(indexableKeysToKeyValues);
8523 for (const key of newKeys) {
8524 if (!oldKeys.has(key)) {
8525 // new doc
8526 const kvDoc = {
8527 _id: key
8528 };
8529 const keyValue = indexableKeysToKeyValues.get(key);
8530 if ('value' in keyValue) {
8531 kvDoc.value = keyValue.value;
8532 }
8533 kvDocs.push(kvDoc);
8534 }
8535 }
8536 metaDoc.keys = uniq(newKeys.concat(metaDoc.keys));
8537 kvDocs.push(metaDoc);
8538
8539 return kvDocs;
8540 }
8541
8542 const metaDoc = await getMetaDoc();
8543 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…